maxentryprocs with mod_fcgi

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suhaskhare
    Member
    Forum ExplorerTechnical Associate
    • Mar 2021
    • 70

    #1

    maxentryprocs with mod_fcgi

    Hello,

    I was able to successfully test LVE restrictions such as CPU limit and maxentryprocs with normal cgi processes. However with mod_fcgid, I am seeing that only CPU limit is being applied. maxentryprocs wasn taking effect.

    I set the below configuration for mod_fcgid..

    <cpu limit="25"></cpu>
    <other maxentryprocs="2"></other>

    Then I simultaneously ran 10 requests for php page, but it didnt deny any of the request as it crossed 2 procs limit. Testing same with normal CGI procs works.

    Regards,
  • iseletsk
    Senior Member
    • Dec 2017
    • 1199

    #2
    The reason Fast CGI was created so that the same script wouldn be run over & over again.
    Instead FastCGI would start a process (script), and then all apache connections will be served by that script.
    FastCGI can span several processes in parallel, but only if needed (and if allowed by config)

    You can find more details here: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
    But you should not be able to exhaust maxentryprocs as only one instance of script is running.

    Comment

    • suhaskhare
      Member
      Forum ExplorerTechnical Associate
      • Mar 2021
      • 70

      #3
      Hi,

      I have set FcgidMaxProcessesPerClass to "2" in httpd.conf and <other maxentryprocs="2"></other> in lve conf.

      > But you should not be able to exhaust maxentryprocs as only one instance of script is running.

      If I got you right, I should not see more than 2 fcgid processes in ps aux output for particular vhost. But with above configuration, I see 3 fcgid processes running in ps aux output.

      Also, can we put static html files, jpg files etc in LVE, especially to use maxentryprocs feature?

      Regards

      Comment

      • suhaskhare
        Member
        Forum ExplorerTechnical Associate
        • Mar 2021
        • 70

        #4
        well, while starting httpd I am seeing this notice..

        "[Sat Apr 17 04:11:05 2010] [notice] mod_fcgid: LVE is disabled"

        And in error_log this..

        "[Mon Apr 12 05:51:20 2010] [warn] [client 172.16.140.48] mod_fcgid: can apply process slot for /var/www/vhost1/index.php"

        I have indeed enabled LVE for fcgid in httpd.conf.

        <IfModule mod_fcgid.c>
        EnableLVE on
        </IfModule>

        Also, I am sure LVE is in effect, as it is limiting CPU usage to 25% as configured in ve.cfg file.

        Code:
        "lveps -d -c 1" output :
        
        LVE    REF    PNO    TNO    UID    GID    CPU    MEM    I/O
        
        501      0      9      9 vhost1 vhost1    25%   6040    N/A
        Dont know why above messages appears.

        Also waiting for my other query.

        > Also, can we put static html files, jpg files etc in LVE, especially to use maxentryprocs feature?

        Regards,

        Comment

        • iseletsk
          Senior Member
          • Dec 2017
          • 1199

          #5
          Putting static files in LVE -- see mod_hostinglimits


          You need to add handler for which it will wrap around
          For example for html files it is plain/html
          There are slight overhead related to LVE, so I am not sure it is such a good idea -- unless those are big files (like move files).

          And it does look like LVE works on your server -- maybe it is mod_hostinglimit, and not mod_fcgid that is putting processes inside?
          Do lve -p to see what is inside each LVE.

          Regarding error with mod_fcgid -- it looks like problem with permissions on /etc/httpd/logs


          Try to resolve that first, and tell me if still complains about LVE.

          Also, which control panel are you using it with?

          Thanks,
          Igor.

          Comment

          • suhaskhare
            Member
            Forum ExplorerTechnical Associate
            • Mar 2021
            • 70

            #6
            Thank you for your response. I could limit static files as suggested by you.

            Also I fixed the "[Sat Apr 17 04:11:05 2010] [notice] mod_fcgid: LVE is disabled" error, it was another file in which LVE was disabled.

            Regarding maxentryprocs="2" for fcgid, I ran apache benchmark for one of the vhost command with following command

            # ab -kc 1000 -t 120 http://192.168.1.155:8080/index.php

            But none of the request got 503 error that maxentryprocs setting causes normally.

            Regards,

            Comment

            • iseletsk
              Senior Member
              • Dec 2017
              • 1199

              #7
              Let me double check how it can be triggered with mod_fcgid.
              The same script will be loaded in memory, and executed once -- so that is why you are not seeing it. I am sure there are settings to make it trigger.
              Or maybe many different scripts in parallel will need to be executed. I am not 100% sure.

              Comment

              • iseletsk
                Senior Member
                • Dec 2017
                • 1199

                #8
                I did some research on mod_fcgid and here is what I found
                1. mod_fcgid has "process manager" that counts the number of processes & can limit them
                1.1 The way to do it looks like to be via FcgidMaxProcessesPerClass. This can limit number of processes on virtual host bases
                1.2 I haven found it to be too reliable
                2. They way mod_fcgid spawns the processes -- we don count them against maxEntryProcs. We still count them as part of CPU usage.
                2.1 We can change that code, and correctly count/reject once it goes over the limit
                2.2 If we do that, mod_fcgid process manager tries to re-spawn those processes (as it decides on its own how many processes have to run) -- just wasting resources.

                So, for now I am thinking of leaving things as they are. I think the best way of using mod_fcgid is my combination of LVE + FcgidMaxProcessesPerClass

                Please, tell me what do you think about such solution.

                Comment

                • suhaskhare
                  Member
                  Forum ExplorerTechnical Associate
                  • Mar 2021
                  • 70

                  #9
                  Hi,

                  As per my understanding, FcgidMaxProcessesPerClass is the max number of fastcgi processes per vhost, which keeps running for serving requests. Whereas maxentryprocs sets a limit on max number of apache children processes per vhost. Both are different.

                  I guess, for every new request for any given vhost, first an apache children process is spawned, and then it passes the request to fastcgi process already running for that domain. If all fastcgi processes are busy in processing earlier requests, new request keeps waiting for it to be free. Thereby it keeps consuming apache children process while waiting. I can see those multiple apache children processes in queue, waiting for fastcgi process to get free in server-status page. So in reality, FcgidMaxProcessesPerClass does not set limit on apache children processes.

                  Hence, I wanted maxentryprocs to limit max number of apache children processes in waiting state.

                  Regards,

                  Comment

                  • iseletsk
                    Senior Member
                    • Dec 2017
                    • 1199

                    #10
                    It makes sense. Though maxEntryProcs would also limit just the number of processes, not apache connections in this case.
                    fgcid has bunch of timeouts but I don see if it have timeout for queued apache processes, and if there is a way to limit number of processes that are queued.

                    Comment

                    • iseletsk
                      Senior Member
                      • Dec 2017
                      • 1199

                      #11
                      I spent a whole day playing with mod_fcgid trying to make sure that apache connection would not get exhausted. I was able to limit number of php/cgi scripts it creates, and with some combination of timeouts -- it almost!!! works.

                      Well, while doing that I figured out a way to limit this using LVE/maxEntryProcs.
                      In reality -- we are not limiting in two places.
                      One: when we accept apache connection/before we contact mod_fcgid daemon
                      Second time -- when we start up cgi processes.

                      Works great so far! You should expect it being out on Tuesday.

                      Comment

                      • suhaskhare
                        Member
                        Forum ExplorerTechnical Associate
                        • Mar 2021
                        • 70

                        #12
                        Excuse me but I am lost here...

                        > In reality -- we are not limiting in two places.
                        > One: when we accept apache connection/before we contact mod_fcgid daemon
                        > Second time -- when we start up cgi processes.

                        Do you mean "We are NOW" instead of "NOT"... or else please elaborate this point...

                        I presume here that you have done code changes to make it work with LVE now. Which RPM should I upgrade to test the same??

                        thanks and regards,

                        Comment

                        • iseletsk
                          Senior Member
                          • Dec 2017
                          • 1199

                          #13
                          I meant now. And yes, we did made code changes. RPMs should be available on Tue.

                          Comment

                          • suhaskhare
                            Member
                            Forum ExplorerTechnical Associate
                            • Mar 2021
                            • 70

                            #14
                            Thank you for the necessary code changes..

                            Which RPM should I upgrade in order to test out new changes... do I need to upgrade lve*, mod_fcgid, httpd all?

                            Also, is there any new configuration directive added??

                            Regards,

                            Comment

                            • iseletsk
                              Senior Member
                              • Dec 2017
                              • 1199

                              #15
                              mod_fcgid package only
                              no new directives. It just uses maxEntryLevel parameter from LVE to track number of apache connections.

                              Comment

                              Working...