简体   繁体   English

设计基于Web的可扩展应用程序的关键因素

[英]Key factors for designing scalable web based application

Currently I am working on web based application. 目前我正在开发基于Web的应用程序。 I want to know what are the key factors a designer should take care while designing scalable web based application ? 我想知道设计人员在设计可扩展的基于Web的应用程序时应该注意哪些关键因素?

That's a fairly vague and broad question and something you could write books about. 这是一个相当模糊和广泛的问题,你可以写一些书。 How far do you take it? 你走多远了? At some point the performance of SQL JOINs breaks down and you have to implement some sharding/partitioning strategy. 在某些时候,SQL JOIN的性能会崩溃,您必须实现一些分片/分区策略。 Is that the level you mean? 这是你的意思吗?

General principles are: 一般原则是:

  • Cache and version all static content (images, CSS, Javascript); 缓存和版本所有静态内容(图像,CSS,Javascript);
  • Put such content on another domain to stop needless cookie traffic; 将此类内容放在另一个域上以阻止不必要的cookie流量;
  • GZip/deflate everything; GZip / deflate一切;
  • Only execute required Javascript; 只执行必需的Javascript;
  • Never do with Javascript what you can do on the serverside (eg style table rows with CSS rather than using fancy jQuery odd/even tricks, which can be a real time killer); 永远不要使用Javascript在服务器端可以做什么(例如使用CSS的样式表行而不是使用花哨的jQuery奇/偶技巧,这可能是一个实时杀手);
  • Keep external HTTP requests to a minimum. 将外部HTTP请求保持在最低限度。 That means very few CSS, Javascript and image files. 这意味着很少有CSS,Javascript和图像文件。 That may mean implementing some form of CSS spriting and/or combining CSS or JS files; 这可能意味着实现某种形式的CSS spriting和/或组合CSS或JS文件;
  • Use serverside caching where necessary but only after you find there's a problem. 必要时使用服务器端缓存,但只有在发现问题后才能使用。 Memory is an expensive but often effective tradeoff for more performance; 内存是一种昂贵但通常有效的权衡,可以获得更高的性能;
  • Test and tune all database queries; 测试并调整所有数据库查询;
  • Minimize redirects. 最小化重定向。

Having a good read of highscalability.com should give you some ideas. 好好阅读highscalability.com应该会给你一些想法。 I highly recommend the Amazon articles. 我强烈推荐亚马逊的文章。

Every application is different. 每个应用程序都不同。 You'll have to profile your application to see where you should concentrate your optimization efforts. 您必须分析您的应用程序,以了解您应该将优化工作集中在哪里。 Some web applications might require database access optimizations, while others have complicated business logic that cause the bottleneck. 某些Web应用程序可能需要数据库访问优化,而其他Web应用程序则具有导致瓶颈的复杂业务逻辑。

Don't attempt to optimize random arbitrary parts of you application without first profiling. 在没有首次分析的情况下,不要尝试优化应用程序的随机任意部分。 You might end up having to support complicated optimized code that doesn't actually make your application snappier. 您可能最终必须支持复杂的优化代码,这些代码实际上并不会使您的应用程序变得更加快捷。

I get the sense from the other answers here that there is a general confusion between scalability and performance. 我从其他答案中得到的结论是,可伸缩性和性能之间存在普遍的混淆。 High performance means that the response is quick. 高性能意味着响应迅速。 High scalability means that you get a response no matter how many others are also using the site at the same time. 高可扩展性意味着无论有多少人同时使用该网站,您都会得到响应。 There's a big difference. 有很大的不同。

In fact, you actually have to sacrifice a little performance just to get good scalability. 实际上,为了获得良好的可伸缩性,您实际上必须牺牲一点性能。 A general pattern to scalability is distributed computing. 可伸缩性的一般模式是分布式计算。 Factoring functionality out into separate tiers of clustered servers (web, business rules, database) is the usual approach to scalability. 将功能分解到不同的集群服务器层(Web,业务规则,数据库)是可扩展性的常用方法。 That extra round trip will slow down page load a little bit. 额外的往返行程会减慢页面加载速度。

Everyone always wants to focus on high scalability but also don't forget that, for software vendors who sell licenses to customers who self host the application, scaling down can be just as important as scaling up. 每个人都希望专注于高可扩展性,但也不要忘记,对于向自托管应用程序的客户销售许可证的软件供应商而言,缩小规模与扩展规模一样重要。 An application that can run on a single server for ten users but can also be configured to run on a ten server web cluster, a three server middle tier, and a four server database cluster for 10,000 users would be a system well designed for scalability. 可以在单个服务器上为10个用户运行但也可以配置为在10个服务器Web集群,3个服务器中间层和4个服务器数据库集群上运行的应用程序,可用于10,000个用户,这是一个专为可扩展性而设计的系统。

None. 没有。 Just code the application using proper design techniques (separation of concerns, etc) and then when the application is done or nearly done, do your performance testing. 只需使用适当的设计技术(关注点分离等)对应用程序进行编码,然后在应用程序完成或接近完成时进行性能测试。 You'll find the real bottlenecks then - they won't be what you might have guessed in the beginning. 你会发现真正的瓶颈 - 它们不会是你在开始时猜到的。 This is where your proper design from the beginning comes into play - it makes it easy to make changes to fix the bottlenecks. 这是您从一开始就正确设计的地方 - 它可以轻松地进行更改以修复瓶颈。

Sometimes, a specific answer is more helpful than just generic tips. 有时,特定答案比通用提示更有帮助。

If you want to scale, the only thing to target is SPEED (in hardware and software) and RESOURCES (in hardware). 如果要扩展,唯一要定位的是SPEED(在硬件和软件中)和RESOURCES(在硬件中)。

Hardware, the latter is expensive (more servers, load-balancers, etc.). 硬件,后者是昂贵的(更多的服务器,负载平衡器等)。

So, by carefully selecting your initial development framework you will save a lot of time and resources -up to several orders of magnitude. 因此,通过仔细选择您的初始开发框架,您将节省大量时间和资源,达到几个数量级。

For example, nginx is (much) faster than Apache. 例如,nginx比Apache快得多。

Other solutions are faster than nginx (for both static and dynamic contents) but I could not disclose them without being censored on StackOverflow (it was rated SPAM & advertising despite the fact that this is a FREE solution). 其他解决方案比nginx更快(对于静态和动态内容)但我无法在没有被StackOverflow审查的情况下透露它们(尽管这是一个免费的解决方案,它被评为垃圾邮件和广告)。

That's the limits of "sharing": we must share only "acceptable" solutions rather than efficient solutions. 这就是“共享”的局限:我们必须只分享“可接受的”解决方案而不是有效的解决方案。

Cheers, 干杯,

Pierre. 皮埃尔。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用于设计可伸缩Web服务的模式 - Pattern for designing a scalable web service 用于 Java EE Web 应用程序的可扩展 UI 框架 - Scalable UI framework for Java EE web application Camel-设计可扩展的动态数据流 - Camel - Designing scalable dynamic dataflow 设计基于密钥的锁(或锁定映射) - Designing a key based lock (or lock map) 如何避免在我非常简单的Web应用程序中泛滥并使其可扩展? - How to avoid flooding in my very simple web application and make it scalable? 设计Web应用程序:业务逻辑应驻留在哪里? - Designing a web-application: where should business logic reside? 如何从基于Java的Web应用程序向ASP.NET MVC应用程序提交键值对象 - How to submit a key value object from java based web application to asp.net mvc application 为高性能,安全,可扩展的Web应用程序选择正确的框架(前端,后端) - Choose right Framework (Frontend, Backend) for high-performance, secure, scalable web application 设计Web平台认证 - Designing a web platform authentication 使用Hazelcast的Java高可伸缩应用程序 - Java high scalable application with Hazelcast
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM