Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Getting query string with CGI::Fast

by hippo (Bishop)
on Jul 28, 2020 at 10:21 UTC ( [id://11119894]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Getting query string with CGI::Fast
in thread Getting query string with CGI::Fast

Suppose the module Myapp uses other modules, are these other modules also stored in memory so they are not loaded for every request?

Short answer: yes.

Any module which a script uses is loaded into memory at compile time, including all the modules used by those modules and so on. This memory stays used until the script exits. For long-running scripts such as those under FCGI this means that all those modules remain in memory for a long time. Each web request to your FCGI script will either encounter an existing FCGI process where all those modules are ready and therefore have no startup penalty or occasionally will have to spin up a fresh FCGI process which will take longer because it loads all the modules.

You can manage this somewhat by loading modules on demand at run-time instead of at compile time. Suppose there's a task your script will need to perform only once in every 10,000 runs and which needs a heavy module. You would not necessarily want that module taking up lots of RAM unnecessarily for 9,999 runs when it isn't needed. This sort of memory and process management is something you will probably want to consider if you are going to use FCGI (or any other persistent back-end) for serious purposes.


🦛

  • Comment on Re^3: Getting query string with CGI::Fast

Replies are listed 'Best First'.
Re^4: Getting query string with CGI::Fast
by Anonymous Monk on Jul 28, 2020 at 12:08 UTC

    I'm using shared hosting. Being new to FCGI, I have absolutely no idea how things would turn out when and if I put the code to use. For the time being, I have the non-FCGI version but have known for a long time FCGI would make things faster. Does the persistence automatically go away after some time of inactivity? Like no request for a certain number of minutes?

      Ordinarily, yes. If you are on shared hosting then I would say definitely so. Your hosting providers will not want shared resources taken up doing nothing. There will also be a maximum number of requests served by any one instance in order to mitigate memory leaks.


      🦛

        I have been checking my test FCGI script from time to time in the last couple hours. I just saw that the counter reset to 0 after some time of inactivity - more than 30 mins I think.

        If I click on it continuously after the first click, the counter increments by one each time. I can now better appreciate a little more what persistence means.

        This ability to respond to a request without spawning a new process each time is indeed a very attractive feature to have. But until today, I didn't know it comes with the cost of using up server resources. Will have to try it out to see how it works on a shared server.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119894]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-25 19:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found