Optimize php5-fpm with apache and 8Gb / 6vcore - apache

I want to optimize the configuration of php5-fpm with apache. On my server I have one site with 4 subdomain all equally important. I configure pool for each subdomain. My server 8Gb of ram and 6vcores. The website will generate a lot of traffic and I would like to optimize at best. On the server running a database mariadb, logwatch, fail2ban, rkhunter, postfix, webmin but nothing more. The server is dedicated to a single site
At the moment in every pool I put:
pm = dynamic
pm.max_children = 150
pm.start_servers = 30
pm.min_spare_servers = 15
pm.max_spare_servers = 40
Can you tell me if it is necessary to add or increase parameter things?
In addition to this I added an APC cache. If you need more information ask me.
Thanks

Related

1 Server Multi cPanel, how the apache work?

i want to ask something about dedicated server.
i have dedicated server and a cPanel website with heavy load, when i check the server load, all parameter didn't go up to 60% usage. but the apache work is high.
so i wonder if i can do this.
i buy dedicated server(DS) and install 2 cPanel on same DS. i know that cPanel need an IP to bind the license so i add 1 additional IP to my DS.
what i am trying to archieve here is to split workload in same website, and to split the traffic i use loadbalancer from CF.
so i have abc.com with 2 different IPs and use LoadBalancer to split the load.
here is why i need to do this
Server load relative low (under 80%)
Apache load relative high 3-10 req/s
There is a problem in your problem definition
What do you mean by Apache work?
if you want have more threads and processes of Apache httpd on the same server, you dont need to install two Cpanel instances, you could tune your Apache httpd worker configuration for a better performance and resource utilization.
you can even use litespeed or nginx web servers on cpanel.

Apache 2.4 configuration in production

I have windows server 2016 in production .
64 GB ram is installed .
Apache 2.4 web sever is installed .
About 1000 concurrent request hit on the server .
Performance is very slow.
What will be the apache configuration to improve performance?
Can any one help?
It might help to post your conf to see if you are currently allowing for 1,000 concurrent connections.
Set ThreadsPerChild to something greater than 1,000, OR just set to 0 to completely remove the limit.

Why would Apache be slow when application server is quick?

We are using Apache as the web server, and it proxies requests to Jboss (think Tomcat) Java application server using AJP.
We have logging on for Apache and for our web application in Jboss.
We are seeing, not always but sometimes, cases where the processing time for a request in Jboss is less than half a second, but in the Apache log for the same request it is taking over 8 seconds to complete the request.
I can't even think where to start looking and I have not come up with a good Google search to try and work out why Apache is sitting on the request for so long. Any help appreciated.
Disclaimer: Educated guess taken from my experience with running such setups.
Preface
Apache can be configured to allow only a limited number of connections at the same time. In fact this is a prudent way to configure Apache since every connection uses a certain amount of resources and having no upper limit puts you at risk to run into a situation, where your main memory is exhausted and your server becomes unresponsive.
Resource exhaustion
That being said, Apache is usually configured as shown below, your numbers and modules may be different though. The principle still applies.
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
This indicates that Apache can process at most 150 concurrent connections.
If a client initiates the 151'th connection, the operating system kernel tries to forward this connection to the Apache process, but it won't answer any more connections. The kernel then enqueues the connection until another connection is closed by Apache.
The time it takes until the kernel can successfully initiate the connection will look to the user as if the request as such takes longer to complete.
The application-server on the other hand, doesn't know about the delay and received the request only after the connection has been initiated. To the application-server therefore everything looks normal.
If you don't have enough resources to increase the concurrent connections in Apache, consider switching to a more resource-efficient web-proxy, like nginx or Varnish.
I don't think apache is acutally slow in your case. I guess you are using keepalived connections between apache and jboss. Under some circumstances, for example the connector is using blocking IO strategy and mean while the number of apache httpd processes are higher than the number of executor threads configurated in jboss connector. It might cause the jboss container thread being blocked after it served a request. You should post your apache and jboss configurations in order to get more specific answers.

Apache server stops

i dont know why; but my apache server is crashing about every hour since this morning .. to overcome the problem, i'm just restarting the apache via service restart httpd command on ssh.
there is no program using ram. when i write TOP comment on ssh, it says 220mb of 8gb ram is free. but niether mysql nor httpd or php etc is using any ram or cpu.
8gb total ram - 7939112 used - 225136 free
top usage:
mysql = 0.7% cpu, 9.3% mem
php = 0.7% cpu, 0.1% mem
httpd = 0.7% cpu, 0 mem
my system details: centos, cpanel, apache
what should i do? i also dont get any error email from cpanel.
Go to task manager to see which of the ones you have listed is taking the most memory. Also if you are using owncloud this is the biggest hoger of memory. Now if it is apache is you need to determine if it is one of the services you have running that is rendering most of the memory. But if it is not of the services and it is apache then you might have try reninstalling apache again. But before you uninstall apache disable mysql or any server type like mysql to see if that could be the issue, if so then there is service running hard that needs to be deleted or checked because is talking to something. Check your task manager and see what is taking the most memory and start from there.

How to make apache slow and unreliable?

I'm writing some code on a mobile device that uses a REST service to retrieve data from a host. That REST services is being proxied by Apache. In test mode I would like to be able to simulate network outages (as if the device has lost it's cell connection) to test the applications handling of intermittent failures. I also need to validate it's behavior with slow network connections.
I'm currently using Traffic Shaper XP to slow the network connection, but now I need something to make the Apache server send connection resets both randomly and on predefined sequences (to setup and repeat specific test scenarios).
I highly recommend https://github.com/Shopify/toxiproxy from Shopify:
Download https://github.com/Shopify/toxiproxy/releases the cli and server
Run the server:
./toxiproxy-server-linux-amd64
On the cli setup proxy to apache on another port e.g. 8080
./toxiproxy-cli create apache -l localhost:8080 -u localhost:80
Make connection slow and unreliable:
./toxiproxy-cli toxic add apache -t latency -a latency=3000
./toxiproxy-cli toxic add apache -t limit_data -a bytes=1000 --tox=0.01
here add 3 second of latency and stop after 1000 bytes for 1% of requests there are other options for bandwidth etc. You can add or remove these during use. Lots of other features and libraries there.
In Apache2 you can make it slow by adjust prefork settings in apache2.conf. The settings below ought to make apache pretty fn slow. They made my local web application take 700% longer to load.
<IfModule mpm_prefork_module>
StartServers 2
MinSpareServers 2
MaxSpareServers 2
MaxClients 4
MaxRequestsPerChild 0
</IfModule>
It looks like DummyNet is the closest thing, but it’s still not quite there. For repeatable testing it would be good to have some control over dropped packets and resets.
Write a little proxy that forwards TCP connections from your app to the apache server and that you can set up in your test to cut the connection after x number of bytes or milliseconds.
On a different (or on the same) computer use the commandline tool ab to get some load on the apache. More informations here.
Is this a Unix or Linux environment? nice it up to give it lower priority then run a high CPU usage task like listening to music, playing a movie, calculating pi, etc. The low priority for Apache should create problems similar to what you're looking for.