Score:0

Apache server is very slow for high traffic

sa flag

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

vidarlo avatar
ar flag
What's your bottleneck? Database, Apache, or processing time for your application?
Muhammad Shafiq avatar
sa flag
Server response time. Apache plus processing time. Server is taking too much time to respond to user
vidarlo avatar
ar flag
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?
Tim avatar
gp flag
Tim
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.
Muhammad Shafiq avatar
sa flag
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?
Score:0
cn flag

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.

Muhammad Shafiq avatar
sa flag
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 avatar
sa flag
Do you suggest me to switch apache to mpm_worker_module? and what should be possible settings for that?
cn flag
I don't understand why "my contents are dynamic and changing frequently" stops you autoscaling.
Muhammad Shafiq avatar
sa flag
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
cn flag
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.
vidarlo avatar
ar flag
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.
jp flag
Optimizing without knowing what is the actual bottleneck is waste of time and resources. Determine what is the actual resources usage and saturation first.
Muhammad Shafiq avatar
sa flag
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?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.