Stack:
Nginx FCGI CGI::Fast HTML::Template::Compiled Redis CentOS Linux 7.9 spawn-fcgi
I have a Perl application that runs on the above stack.
On process init it does a lot of loading of big hashes and other data into global variables that are mostly preloaded and cached in a distributed Redis install.
To start the application spawn-fcgi creates 6-8 processes on a port nginx then connects to trhough their fcgi module.
The challenge:
— The init process is computing and time consuming; and doing that concurrently six times peaks CPU and overall leads to a ~20-25 second delay before the next web request can be served. And the initial request to each of the six processes has that delay.
I tried loading the content in question directly from Redis on demand but the performance keeping it in memory is naturally much better (minus the initial delay).
is there an architectural pattern that I am not considering here? I am thinking of things as eg. only spinning up one process, having it initialize and then clone(?) it a few times for serving more requests.
I could also think of a way where only 1 process is spawned at a time and once it completes initiation the next one starts; would need to verify that spawn-fcgi can support this.
So my question to this community is if I am missing an obvious better solution than what is in place right now / what I am considering.
Thanks in advance.
submitted by /u/kosaromepr
[link] [comments]