0

I am using Apache 2 on AWS ec2 instance. I have application load balancer with 2 instances/servers attached to it. Each instance type is m5.8XLarge.

My application is developed in Laravel, I am using RDS.

I am having 300,000 visitors per day and 10,000 visitors at a time. My website is very slow and initial server response time is very high upto 8 sec.

Note: I can not use autoscalling because my contents are dynamic, and changing frequently. Autoscaling is using old IMG.

I am having below extra settings on httpd.conf file

 MaxKeepAliveRequests 500
 Keepalive On
 KeepAliveTimeout 5
 HostnameLookups Off

<IfModule prefork.c>
  StartServers        5
  MinSpareServers     20
  MaxSpareServers     40
  MaxClients          200
  MaxRequestsPerChild 4000
</IfModule>

How i can improve the server speed and allow apache to handle much load/visitors

  • What's your bottleneck? Database, Apache, or processing time for your application? – vidarlo Jan 27 '22 at 09:57
  • Server response time. Apache plus processing time. Server is taking too much time to respond to user – Muhammad Shafiq Jan 27 '22 at 10:36
  • 3
    Yes, that's the end result. But do you have any idea how this time is built up? Is it waiting for database, busy processing your application, or busy reading from disk? – vidarlo Jan 27 '22 at 11:48
  • You need to spend some time working out what the limit is. You also need to use a cloud model for deployment, for example putting your shared images on EFS rather than on servers. Servers in the cloud should ideally be considered ephemeral (temporary) and able to be replaced at any time, that way you can scale up and down more easily. Scaling with smaller cheaper servers reduces cost at low load and helps avoid bottlenecks in one server. – Tim Jan 27 '22 at 18:34
  • I am using S3 & CloudFront as CDN for images & Files. On home page there is no connectivity to database. So only thing to check if Apache and laravel application. Do you suggest to convert apache mpm to worker? – Muhammad Shafiq Jan 31 '22 at 06:25

1 Answers1

0

You should look at using an Auto Scaling Group to scale your application horizontally if possible. A single server will always reach a limit of performance - this is why we use load balancers. If you are already using 2 instances, just add more! As long as your architecture will support it.

If not, you can scale vertically by using a larger EC2 instance. You don't say what instance you are currently using, so I can't give any recommendations.

shearn89
  • 3,403
  • 2
  • 15
  • 39
  • I added more explanation to question. I can not use autoscaling because my contents are dynamic, and changing frequently. Autoscaling is using old IMAGs. Also I am using 2 servers of m5.8xlarge ec2 types – Muhammad Shafiq Jan 27 '22 at 09:19
  • Do you suggest me to switch apache to mpm_worker_module? and what should be possible settings for that? – Muhammad Shafiq Jan 27 '22 at 09:20
  • I don't understand why "my contents are dynamic and changing frequently" stops you autoscaling. – shearn89 Jan 27 '22 at 10:57
  • AWS Auto Scaling uses instance image to launch new instances. That image will have old contents so the newly launched instance will also have old contents. From contents i means if i upload or update some images,html,css or php files to my website – Muhammad Shafiq Jan 27 '22 at 11:06
  • You can use the userdata when you provision the image to customise the deployment. You can also put static assets like images in S3 and update them seperately. It may be best to investigate some training on AWS via an online provider as it may give you lots more background info than we can here. – shearn89 Jan 27 '22 at 12:05
  • 1
    You're basically attempting to deploy *traditional* way in a cloud environment. Don't do that. Leverage cloud - separate data and logic, so that the logic can be a docker container accessing data - either static from S3 or dynamic from a database. This makes scaling easy; spin up more containers when needed. I would agree with @shearn89 - teach yourself on how to leverage cloud, and how to scale in a cloud environment. – vidarlo Jan 27 '22 at 12:53
  • Optimizing without knowing what is the actual bottleneck is waste of time and resources. Determine what is the actual resources usage and saturation first. – AlexD Jan 27 '22 at 14:27
  • I am talking about home page speed, on home page there is no connectivity to database. Do I need to convert apache MPM from prefork to worker? – Muhammad Shafiq Jan 31 '22 at 06:19