Apache - Heavy load

Discussion in 'Apache' started by agriz, Jan 9, 2012.

  1. #1
    Hi

    I am getting approx 300 to 400 hits every second.
    Apache is struggling to handle this.

    The site is very slow in loading. How to improve the performance of httpd?

    Thanks
     
    agriz, Jan 9, 2012 IP
  2. GMF

    GMF Well-Known Member

    Messages:
    855
    Likes Received:
    113
    Best Answers:
    19
    Trophy Points:
    145
    #2
    Well, what kind of hosting have you? Shared? VPS?
    How big are your files? Any big images to load? Heavy scripts?

    some more info please
     
    GMF, Jan 9, 2012 IP
  3. agriz

    agriz Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Dedicated server.
    i7, 8gb ram

    It was working good yesterday. Today the traffic become little higher than yesterday and it is loading very slowly.

    I have webmin control panel which loads very fast as usual. But site's performance is very slow.
    I just uploaded a text file and a html file. Both took 10 to 20 seconds to load.
     
    agriz, Jan 9, 2012 IP
  4. sabin

    sabin Well-Known Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    #4
    Do you have munin ? Awesomely useful to know where your server is hitting a bottleneck. It comes with Virtualmin, I know, but I don't know if it comes with webmin by default.

    If you don't have enough CPU or RAM, you'll need a better machine or you'll have to optimize the website's software.

    If you're running slow on Apache threads ("apache processes", in Munin, if your graph shows the dark green lower area not fluctuating but making a horizontal line, it's your bottleneck), however, then
    in
    /etc/apache2/apache2.conf
    Around line 100, find ServerLimit and MaxClients and increase these a bit.
    Watch out, it can suck out your RAM or CPU verrrry fast, don't increase them too much.
     
    sabin, Jan 9, 2012 IP
  5. agriz

    agriz Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    I dont have munin.
    Can i install it now?

    I have lot of free ram and cpu. But the loading is very slow.
    As i already mentioned, the site is slow, but webmin is faster.

    I dont know what could be the problem :(

    I have already increased those values in httpd.conf
    But still there is no improvement.

    prefork MPM


    <IfModule prefork.c>
    StartServers 50
    MinSpareServers 15
    MaxSpareServers 30
    ServerLimit 256
    MaxClients 225
    MaxRequestsPerChild 4000
    </IfModule>
     
    agriz, Jan 9, 2012 IP
  6. sabin

    sabin Well-Known Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    #6
    Ah, it's something else for me (recent intel quad core, 16 GB ram), so, sorry, I can't help.
    Just in case, my config :
    <IfModule mpm_prefork_module>
    StartServers 5
    MinSpareServers 5
    MaxSpareServers 10
    ServerLimit 400
    MaxClients 400
    MaxRequestsPerChild 1000
    </IfModule>
     
    sabin, Jan 9, 2012 IP
  7. agriz

    agriz Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #7
    I found the problem. It is dos attack.

    in messages.
    I have installed csf and and enabled the following.
    CT_LIMIT = 25 and SYNFLOOD = 1

    What else should i do now to avoid it?
     
    agriz, Jan 9, 2012 IP
  8. SolidShellSecurity

    SolidShellSecurity Banned

    Messages:
    262
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    45
    #8
    Have you done any kernel hardening? Tweaked the synflood settings? Installed a reverse proxy like maybe nginx?
     
    SolidShellSecurity, Jan 11, 2012 IP
  9. agriz

    agriz Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #9
    No.
    I have installed only CSF and module to to apache to control the too many connections.
    But the IP range are quite different so, the methods are not working :(
     
    agriz, Jan 11, 2012 IP
  10. agriz

    agriz Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #10
    I hired a freelancer. He is not much good. But he is saying that it is not an attack.
    How do i optimize httpd.conf to handle huge traffic?

    My current settings.
     
    agriz, Jan 12, 2012 IP
  11. SolidShellSecurity

    SolidShellSecurity Banned

    Messages:
    262
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    45
    #11
    Have you looked into maybe using nginx as a frontend/reverse proxy to handle and take some of the load off apache?
     
    SolidShellSecurity, Jan 13, 2012 IP
  12. agriz

    agriz Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #12
    How can i do it?
    Do i need to use both Nginx and Apache?

    Do you have any how to link?

    Thanks
     
    agriz, Jan 13, 2012 IP
  13. SolidShellSecurity

    SolidShellSecurity Banned

    Messages:
    262
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    45
    #13
    You can use nginx to serve static and cache it all and proxy the dynamic to apache. Google "nginx reverse proxy" it will get you started. The installation is pretty straight forward. PM if you have any issues or problems.
     
    SolidShellSecurity, Jan 13, 2012 IP
  14. agriz

    agriz Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #14
    Thanks for the advice, I will look on it. If i struck, I will send you PM
     
    agriz, Jan 13, 2012 IP
  15. ideamine

    ideamine Member

    Messages:
    83
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    28
    #15
    what is your server configuration ... i would advise you to increase the follwoing :
    ServerLimit 400
    MaxClients 400

    Nginx will perform better in high traffic sites :) Just let me know or pm me if you want any help :D

    Take care
     
    ideamine, Jan 30, 2012 IP