开发者

What are good priciples for creating a scalable website?

What are good priciples for creatin开发者_高级运维g a scalable website predominantly C#? What design patterns are more common for a C# based website? Links to good books or articles are welcome.


I think these apply to all websites, not just C#

Set proper expectations

Scaling means different things at different times. Are you trying to scale up from your 1000 beta users, to 100,000 active users on launch day? Are you trying to handle constant growth without refactoring? Do you just want to make sure if there's a good old "Slashdot" effect on your site, you can handle it? These all require scalability, but some are very different than others.

Calculate the value of data

Often times people freak out about data loss. But really what people mean to freak out about is data consistency. I won't be really mad if the account I created 30 seconds ago disappears. I will be mad if the photo I uploaded of my trip to Prague is replaced by Halloween Harlots downing beer bongs. So if you are able to calculate the risk of data loss, its a fairly easy process to then calculate the impact, and make a real business decision on whether or not its ok, and if so, how much before it hurts you.

Simplicity trumps Coolness

I love block diagrams as much as anyone else, but how many times have you heard someone go "DAMN, this TV is SO WELL DESIGNED I have to buy it." More often than not they'll say things like "Sony hasn't let me down, and this TV LOOKS great, I have to have it!" Keeping things simple and modular, even if it means NOT using some really cool, ultra-abstracted infinitely scalable pattern, will allow you to scale when and where you need it.

You will not always be alone

The toughest part of your website (and any business) to scale is always people. Sure, by the time you need more engineers, you should be rolling in money so you can just hire 10 people and they'll rewrite the site to be maintainable. However, if you can just hire 2, and they don't immediately surf to the daily wtf to post your entire code base in a 7 part exposé ... you should come out ahead.


This is hard to answer without more details about your architecture.

Which version of .NET and C# are you using?

Are you using MVC or webforms?

Do you have multiple webservers connecting to one database?

When designing a website for scalability I start with having a lot of javascript that will be the controller, pulling information from the webservice, either a WCF app or .asmx service. This way the webserver serves out the pages, but after that the rendering is done by the javascript. This helps relieve stress on the webserver.

If you can have the webserver have all the static content and for any business logic have the code-behind call to another server that will do the processing, get info from the database and return back to the code-behind.

By having this separation, if you need to add more servers in one layer you can determine which part needs extra horsepower, and ensure that the webserver is only really doing one task, interfacing with the browsers.

If you could go into more detail about your architecture it would be helpful, as well as how much of a load you are planning for, then it would be easier to give a more detailed response.


Martin Fowler's Patterns of Enterprise Application Architecture (summaries on his website) are a good place to start. There's an awful, awful lot of components and technologies that can go into building a scalable website... load balancing, caching, application serving, database setup, networking, and somewhere in there is the actual code being written.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜