I'm a fan of MVC because I've found it easier to scale your team when everything has a place and is nice and compartmentalized. It takes some getting used to, but the easiest way to get a handle on it is to dive in.
That said definitely check your local library to see if they have the O'Reilley book on scaling: http://oreilly.com/catalog/9780596102357 which is a good place to start.
如果您正在创建一个“大”网站并且没有完全掌握 MVC 或 Web 框架,那么 CMS 可能是更好的途径,因为您可以使用您认为合适的插件对其进行扩展。通过这种方式,您可以更多地担心内容和页面结构,而不是平台。只要您选择合适的CMS。
If you're creating a "big" website and don't fully grasp MVC or a web framework then a CMS might be a better route since you can expand it with plugins as you see fit. With this route you can worry more about the content and page structure rather than the platform. As long as you pick the appropriate CMS.
我建议使用一些野外的 Web MVC 框架创建一个模拟应用程序,并选择一个让您的开发足够顺利的框架。如果您想掌握 MVC 的概念并准备好轻松地向您的 Web 添加新功能,那么在坚实的基础上建立代码是基础。
I would suggest to create a mock app with some of the web mvc frameworks in the wild and pick one, with which your development was smooth enough. Establishing your code on a solid basis is fundamental, if you want to grasp concepts of mvc and be ready to add new functionality to your web easily.
Scalability/availability (iow. high-traffic) for websites is best addressed by none of the items you mention. Especially points 1 and 2; storing the page definitions in a database is an absolute no-no. MVC and other similar patterns are more for code clarity and maintenance, not for scalability.
An important piece of missing information is what kind of concurrent hits/sec are you expecting? Sometimes, people who haven't built high-traffic websites are surprised at the hit rates that actually constitute a "scalability nightmare".
There are books on how to design scalable architectures, so an SO post will not be able to the topic justice, but some very top-level concepts, in no particular order, are:
Scalability is best handled first by looking at hardware-based solutions. A beefy server with an array of SSD disks can go a long way.
Make static anything that can be static. Serve as much as you can from the web server, not the DB. For example, a lot of pages on websites dynamically generate data lists out of databases from data stores that very rarely or never really change.
Cache output that changes infrequently, and tune the cache refresh.
Build dynamic pages to be stateless or asynchronous. Look into CQRS and Event Sourcing for patterns that favor/facilitate scaling.
Tune your queries. The DB is usually the big bottleneck since it is a shared resource. Lots of web app builders use ORMs that create poor queries.
Tune your database engine. Backups, replication, sweeping, logging, all of these require just a little bit of resource from your engine. Tuning it can lead to a faster DB that buys you time from a scale-out.
Reduce the number of HTTP requests from clients. Each HTTP connect has overhead. Check your pages and see if you can increase the payload in each request so as to reduce the overall number of individual requests.
At this point, you've optimized the behavior on one server, and you have to "scale out". Now, things get very complicated very fast. Load-balancing scenarios of various types (sharding, DNS-driven, dumb balancing, etc), separating read data from write data on different DBs, going to a virtualization solution like Google Apps, offload static content to a big CDN service, use a language like Erlang or Scala and parallelize your app, etc...
Single entry point, pages data in the database, pulled by associating GET variable with database entry (?pageid=whatever)
Potential nightmare for maintenance. And also for development if you have team of more than 2-3 people. You would need to create a set of strict rules for everyone to adhere to - effort that would be much better spent if using MVC. Same goes for 2.
MVC (Alright guys, I'm all for it, but can't grasp the concept besides checking all tutorials and frameworks out there, do they store "view" in database? Seems to me from examples that if you have 1000 pages of same kind they can be shaped by 1 model, but I'll still need to have 1000 "views" files?)
It depends how many page layouts are there. Most MVC frameworks allow you to work with structured views (i.e. main page views, sub-views). Think of a view as HTML template for the web page. How many templates and sub-templates inside you need is exactly how many view's you'll have. I believe most websites can get away with up to 50 main views and up to 100 subviews - but those are very large sites. Looking at some sites I run, it's more like 50 views in total.
DAL/DAO/DDD - i learned about these terms by diligently reading through stack overflow before posting question. Not sure if it belongs to this list
It does. DDD is great if you need meta-views or meta-models. Say, if all your models are quite similar in structure, but differ only in database tables used and your views almost map 1:1 to models. In that case, it is a good time for DDD. A good example is some ERP software where you don't need a separate design for all the database tables, you can use some uniform way to do all the CRUD operations. In this case you could probably get away with one model and a couple of views - all generated dynamically at run-time using meta-model that maps database columns, types and rules to logic of programming language. But, please note that it does take some time and effort to build a quality DDD engine so that your application doesn't look like hacked-up MS Access program.
Sit down and create my own architecture (likely to do if nobody enlightens me here:)
If you're building a public-facing website, you're most likely going to do it well with MVC. A very good starting point is to look at CodeIgniter video tutorials. It helped me understand what MVC really is and how to use it way better than any HOWTO or manual I read. And they only take 29minutes altogether:
发布评论
评论(5)
我是 MVC 的粉丝,因为我发现当所有东西都有一个位置并且很好且划分时,扩展团队会更容易。这需要一些时间来适应,但掌握它的最简单方法就是深入研究。
也就是说,一定要检查您当地的图书馆,看看他们是否有 O'Reilley 有关缩放的书: http://oreilly.com/catalog/9780596102357 这是一个很好的起点。
I'm a fan of MVC because I've found it easier to scale your team when everything has a place and is nice and compartmentalized. It takes some getting used to, but the easiest way to get a handle on it is to dive in.
That said definitely check your local library to see if they have the O'Reilley book on scaling: http://oreilly.com/catalog/9780596102357 which is a good place to start.
如果您正在创建一个“大”网站并且没有完全掌握 MVC 或 Web 框架,那么 CMS 可能是更好的途径,因为您可以使用您认为合适的插件对其进行扩展。通过这种方式,您可以更多地担心内容和页面结构,而不是平台。只要您选择合适的CMS。
If you're creating a "big" website and don't fully grasp MVC or a web framework then a CMS might be a better route since you can expand it with plugins as you see fit. With this route you can worry more about the content and page structure rather than the platform. As long as you pick the appropriate CMS.
我建议使用一些野外的 Web MVC 框架创建一个模拟应用程序,并选择一个让您的开发足够顺利的框架。如果您想掌握 MVC 的概念并准备好轻松地向您的 Web 添加新功能,那么在坚实的基础上建立代码是基础。
I would suggest to create a mock app with some of the web mvc frameworks in the wild and pick one, with which your development was smooth enough. Establishing your code on a solid basis is fundamental, if you want to grasp concepts of mvc and be ready to add new functionality to your web easily.
您提到的任何一项都不能最好地解决网站的可扩展性/可用性(即高流量)问题。特别是第1点和第2点;将页面定义存储在数据库中是绝对不允许的。 MVC 和其他类似的模式更多的是为了代码的清晰度和可维护性,而不是为了可扩展性。
缺少的一个重要信息是您期望每秒的并发点击量是多少?有时,那些没有建立过高流量网站的人会对点击率感到惊讶,这实际上构成了“可扩展性噩梦”。
有一些关于如何设计可扩展架构的书籍,因此 SO 帖子将无法公正地阐述该主题,但一些非常顶级的概念(排名不分先后)是:
此时,您已经优化了一台服务器上的行为,并且必须“横向扩展”。现在,事情很快变得非常复杂。各种类型的负载平衡场景(分片、DNS 驱动、哑平衡等)、将不同数据库上的读取数据与写入数据分开、使用 Google Apps 等虚拟化解决方案、将静态内容卸载到大型 CDN 服务、使用像 Erlang 或 Scala 这样的语言并并行化您的应用程序等......
Scalability/availability (iow. high-traffic) for websites is best addressed by none of the items you mention. Especially points 1 and 2; storing the page definitions in a database is an absolute no-no. MVC and other similar patterns are more for code clarity and maintenance, not for scalability.
An important piece of missing information is what kind of concurrent hits/sec are you expecting? Sometimes, people who haven't built high-traffic websites are surprised at the hit rates that actually constitute a "scalability nightmare".
There are books on how to design scalable architectures, so an SO post will not be able to the topic justice, but some very top-level concepts, in no particular order, are:
At this point, you've optimized the behavior on one server, and you have to "scale out". Now, things get very complicated very fast. Load-balancing scenarios of various types (sharding, DNS-driven, dumb balancing, etc), separating read data from write data on different DBs, going to a virtualization solution like Google Apps, offload static content to a big CDN service, use a language like Erlang or Scala and parallelize your app, etc...
维护的潜在噩梦。如果您的团队超过 2-3 人,也可用于开发。您需要创建一套严格的规则供每个人遵守 - 如果使用 MVC,这些努力会更好。 2 也同样如此。
这取决于有多少页面布局。大多数 MVC 框架允许您使用结构化视图(即主页面视图、子视图)。将视图视为网页的 HTML 模板。您需要的模板和子模板的数量正是您将拥有的视图的数量。我相信大多数网站都可以容纳最多 50 个主视图和最多 100 个子视图 - 但这些都是非常大的网站。看看我运行的一些网站,总共有 50 次浏览。
确实如此。如果您需要元视图或元模型,那么 DDD 非常有用。假设您的所有模型在结构上都非常相似,但仅在使用的数据库表方面有所不同,并且您的视图几乎 1:1 映射到模型。在这种情况下,这是 DDD 的好时机。一个很好的例子是一些ERP软件,您不需要为所有数据库表单独设计,您可以使用某种统一的方式来完成所有CRUD操作。在这种情况下,您可能可以使用一个模型和几个视图 - 所有这些都是在运行时使用元模型动态生成的,该元模型将数据库列、类型和规则映射到编程语言的逻辑。但是,请注意,构建高质量的 DDD 引擎确实需要一些时间和精力,以便您的应用程序看起来不像被黑客攻击的 MS Access 程序。
如果您正在构建一个面向公众的网站,那么您很可能会使用 MVC 做得很好。一个很好的起点是观看 CodeIgniter 视频教程。它帮助我比我读过的任何 HOWTO 或手册更好地理解 MVC 到底是什么以及如何使用它。它们总共只需要 29 分钟:
http://codeigniter.com/tutorials/
尽情享受吧。
Potential nightmare for maintenance. And also for development if you have team of more than 2-3 people. You would need to create a set of strict rules for everyone to adhere to - effort that would be much better spent if using MVC. Same goes for 2.
It depends how many page layouts are there. Most MVC frameworks allow you to work with structured views (i.e. main page views, sub-views). Think of a view as HTML template for the web page. How many templates and sub-templates inside you need is exactly how many view's you'll have. I believe most websites can get away with up to 50 main views and up to 100 subviews - but those are very large sites. Looking at some sites I run, it's more like 50 views in total.
It does. DDD is great if you need meta-views or meta-models. Say, if all your models are quite similar in structure, but differ only in database tables used and your views almost map 1:1 to models. In that case, it is a good time for DDD. A good example is some ERP software where you don't need a separate design for all the database tables, you can use some uniform way to do all the CRUD operations. In this case you could probably get away with one model and a couple of views - all generated dynamically at run-time using meta-model that maps database columns, types and rules to logic of programming language. But, please note that it does take some time and effort to build a quality DDD engine so that your application doesn't look like hacked-up MS Access program.
If you're building a public-facing website, you're most likely going to do it well with MVC. A very good starting point is to look at CodeIgniter video tutorials. It helped me understand what MVC really is and how to use it way better than any HOWTO or manual I read. And they only take 29minutes altogether:
http://codeigniter.com/tutorials/
Enjoy.