2

I currently have an AWS EC2 instance m5.24xlarge that has :

  • 96 vCPU
  • 384 RAM
  • 25 GBPs network

We are currently expecting more than 50 000 concurrent users online, I have added a layer on cloudflare but the issue is I keep getting server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting on apache error_log.

What are the best settings for apache in order to handle this kind of traffic?

KeepLearning
  • 635
  • 7
  • 10
BarNation
  • 21
  • 3

2 Answers2

3

I'm afraid you are doing it wrong. Instead of running one massive mega-instance you should run a fleet of smaller instances behind a load-balancer. For example replace m5.24xlarge with 24 x m5.xlarge, ideally in an auto-scaling group with spot instances to save costs.

Some of the reasons are:

  • If your big instance fails or needs maintenance your whole website goes down. If the same happens to one of the smaller instances you only lose 1/24 of you capacity.

  • You can add and remove capacity when your traffic changes, for example automatically shut down some instances over the weekend or overnight when there's less demand. Saves you money.

  • You can automate recovery of failed instances, you can use spot instances to save some more money, etc.

Having said that you may need to re-architect your application a little. For example if the database is currently running on the same instance you will have to move it to AWS Aurora so that all the instances can use it.

Same for the filesystem - if your app stores user data locally you may need to introduce a shared filesystem, e.g. AWS EFS - Elastic File System.

There is some work involved but there are massive benefits of scaling horizontally (adding more smaller workers to do the job) vs vertically (making a single worker bigger and bigger).

Hope that helps :)

MLu
  • 23,798
  • 5
  • 54
  • 81
1

Scaling up on a very large web server instance is in fact possible.

As httpd's warning suggests, you will need to tune the MPM. First select an MPM. event is nice and performant, but depending on your modules you may need prefork.

MaxRequestWorkers was formerly known as MaxClient. Increase this as much as your memory allows. Take for example the simple procedure from How to calculate the MaxClient value in apache? Assume say 350 GB of memory can be used, the rest is for OS and other overheads. Divide by the per process RSS from top. Say it is 50 MB, and the result is something over 7000. This is your first guess at MaxRequestWorkers. ServerLimit also needs to be greater than this, try 10000.

Watch user response time under load to see how it does. 50,000 concurrent users may not need quite that many workers to keep serving requests, but it varies a lot depending on application.

As you keep an eye on things, plan your next tuning change experiment. Perhaps increasing ThreadsPerChild will allow a smaller number of processes and corresponding reduced memory use.

50k is more than the default ephemeral port range on more operating systems. If all your traffic comes from the same load balancer IP and port, look into ways to get around that.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32