I have problem with many sleeps scripts on apache. While i start apache, and clear cached memory to 13GB free, then free memory still falling to ap. 100MB free. Many php processes going to sleep and keeps cached memory ap. 19 MB on one script.
Sometime sleep script keep even 700MB from memory. Is some setting, how tell apache when script end, then process end to?
No your problem isn’t “with many sleeps scripts on apache”, is that you are using sleeps scripts on apache. Sleeping is an anathema to most web servers which are designed with one purpose in mind: to receive and to respond to stateless HTTP(S) based web requests.
Sleeping, per se, isn’t an absolute evil but if the total delay is more than a few seconds then you are doing something very wrong, and you need to explore alternative approaches.
For example, phpBB implements a pseudo-cron type function where web requests schedules future work activities (e.g. to application-related table maintenance every hour, say) by using a queued-request table and a common check function. If a scheduled task is due a one-pixel image request is used to generate an async call-back to action the activity. (By doing an image load this request is decoupled from the URI that incidentally triggered it.
Another approach is a variant which uses independent daemon or cron job to service this queued-request table.
Another approach is simply to execute a child process which then forks to daemonise itself and detach from the Apache worker process.
And another approach …