Solving problems with congested web servers

I am new to web development and currently interviewing companies, favorite questions among people asking:

How do you scale your web server if it starts to hit a million requests?

What would you do if you only have one database instance running at that time? how do you do it?

These questions are really interesting, and I would like to know about them. Please attach your suggestions / practices (which you follow) for such scenarios

thanks

+4
source share
6 answers

How to scale:

  • Identify your bottlenecks.
  • Determine the correct solution to the problem.
  • Make sure you can implement the right solution.
  • Identify an alternative solution and check

Typical scaling options:

  • Vertical scaling (larger, faster server hardware)
  • Load balancing
  • Divide levels / components into other / different equipment.
  • Working with booting via caching / cdn

Database Scaling Options:

  • Vertical scaling (larger, faster server hardware)
  • Replication (active or passive)
  • Clustering (if the DBMS supports it)
  • Sharding
+7
source

At the most basic level, scaling web servers consists of writing your application so that it can run on> 1 machine and throw more machines into the problem. No matter how you configure them, possible scaling will include a web server farm.

The database problem is more sticky. What is your read / write percentage? What kind of app is this? OLTP? OLAP? Social media? What is a database? How to add more servers to handle the load? Do we share data across multiple dbs? Or copy all changes to the load of slaves?

Your questions are asked more questions, that is, in an interview, if someone simply β€œhas an answer” to a general question, for example, you posted, then they know only one way to do things, and this way may or may not be the best.

+4
source

There are several approaches to the first question:

  • Are there any hardware updates that can get everything to handle millions of requests in a short time? If so, this is most likely the starting point for the study.

  • Are there any software changes to optimize server performance? I know that IIS has a ton of different tweaks that can be used to improve performance to some extent.

  • Consider migrating to a web farm rather than using a single server. I actually had a situation when I worked once, when we had millions of hits per minute, and this greatly ruined our web servers and deleted several sites. Our solution was to change the load balancer, so that several servers serve the site, which breaks down the servers, so that other servers can support other sites, as it was in the fall, and in retail this is your big quarter. While some of them start here, I will probably come here last, as this may open the worm bit worm compared to the other two options.

As for the database instance, it will be a similar set of options for my mind, although I can make the option with multiple servers, as redundancy can be an important side benefit here, I'm not sure if it is just as easy with a web server. I may leave, but that is how I began to do this.

+3
source

Use Caching Proxy

If you serve the same pages for all visitors (for example, a news site), you can reduce the load by an order by caching the generated content using a caching proxy, for example, Varnish or Apache Traffic Server .

A proxy server will be located between your server and your visitors. If you receive 10,000 hits on your first page, you only need to create it once, the proxy will send the same response to other 9999 visitors, without asking your application server again.

+3
source

maybe before the developer begins to develop the system, they will consider the server specification maybe you can reduce the use of SEO and block it from the search engine to crop it (this is a task that requires a lot of resources) try to index everything and avoid an easy search.

0
source
  • Deploy it in the cloud, make sure your web server and webapp cloud are ready and can scale in different nodes. I recommend the cherokee web server (it’s very easy to load the balance on different servers, and the tests show faster than Apache). For example, the Google Cloud (appspot) requires your web application to be Python or Java

  • Use a caching proxy, for example. Nginx.

  • To use the memcache database in some queries that are supposed to be repeated.

  • If the company wants the data to be private, create a private cloud. Here, Ubuntu does an excellent job of this completely and for free: http://www.ubuntu.com/cloud/private

-1
source

All Articles