How do you rewrite / redesign a website to scale?

How do you rewrite a website to scale? (traffic) I mainly work with PHP and some Ruby on rails, and I know its general question. I just want to increase my knowledge, so any advice will be useful.

Thank you in advance, -)

+4
source share
4 answers

This is a fairly broad question, and it will be quite difficult to give you a specific answer, but a few ideas:

  • First of all, do not pre-optimize!
    • Make sure your application is running; most importantly.
    • And only when it becomes necessary, start optimization.
  • PHP itself usually scales well:
    • Add a couple more Apache + PHP servers, load user balance.
    • And it works very easily.
  • The file system does not scale so well / easily:
    • it is not used on all servers
    • A shared file system (such as with NFS) can sometimes cause problems.
  • The database is usually the hardest part when it comes to scaling:
    • Having multiple "write" servers is difficult.
    • Having more than a few read servers that typically use replication can be a pain for maintenance
    • You will have to think about what will be fined someday if replication is not enough.
  • Use a lot of caching: the more cache you can use, the less queries you will make in the database, the better
    • memcached is wonderful and scales well: just add a couple of servers and you get a couple more GB or memory in the cache cluster
  • Using a reverse proxy, so your Apache + PHP servers have fewer features to work with, also helps.


And a quick link that can give you some ideas:

+14
source

One tip is cache data using memcached or the equivalent instead of directly querying the database.

In addition, the hardest part of scaling is moving outside of a single web server. Once you can scale up to two web servers, you do not need to scale many problems for many others.

+2
source

Get a PHP accelerator, you will probably have a noticeable increase in performance, Wikipedia has a good list to choose from. And, as Justin said, getting memcached is awesome.

0
source

A β€œscale” is not a universal, concrete phenomenon, but a relative measure of productivity and capacity according to a specific set of criteria. Therefore, in order for this conversation to make any sense, you need a set of criteria and some indicators.

I found Apdex to be a very useful mechanism for thinking and reasoning about required metrics:

Apdex (Application Performance Index) is an open standard developed by an alliance of companies that defines a standardized reporting method, benchmarking, and application performance tracking.

The beauty of a system, such as the Apdex index, is that it is directly related to how users perceive a satisfactory application response. This is the only thing that really matters in any discussion of scale and performance.

So, for example, when you think of your system in this way, you determine the response speed necessary to satisfy the response expected by the user, you evaluate the level of traffic that you need to support, and then add capacity to achieve your goals,

0
source

Source: https://habr.com/ru/post/1302771/


All Articles