Hibernate/Suspend mode for HTTP Server

I wonder if web server ever goes to sleep (hibernate/suspend mode)? And if a visitor's browser asks for a web page, then the web server immediately wakes up? Is it really an option or pure fantasy?
The reason why I'm asking... I don't know how big should be swap file. Generally the system never uses it (no need!). But if the web server would go to sleep, then it's different...
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dr. KlahnPrincipal Software EngineerCommented:
Apache operates on a dynamic basis.  When demand increases, it adds child processes until it reaches the configuration specified maximum.  When demand reduces, it terminates child processes until it reaches the specified minimum.  It never ends up with no child processes, so it does not really ever go into an "idle" state where it is not ready for the next request and must bring itself back into running state.

I look at the memory requirements for Apache and its children right after Apache starts and consider that the minimum load.  Depending on the maximum number of child processes you have configured, you can figure the absolute maximum that Apache and its children would ever require.

On my system Apache never swaps, and that is a small system with only 512 MB memory.
papakotaAuthor Commented:
Thanks for your reply! I have 6 GB of DDR3 memory. So if Apache never sleeps, then what's the point to have a big swap file?
Dr. KlahnPrincipal Software EngineerCommented:
Well ... here's a fabricated case.

You have a server set up with the maximum child processes set to 200.  Somebody makes a social media posting saying how great your site is.  Suddenly your site is hit by 100x the normal load.  Instead of Apache hitting the usual child limit of 20 or 30 and then (mostly) returning error messages that the server is overloaded, it will go to 200 child processes.  The child processes all start fighting for available memory and they swap in and out like mad, but they do return pages ... eventually. This is arguably not a better thing to happen, but again, this is a fabricated case.

In a normal situation, if there is no other application running on the system that gobbles swap space, a large swap file is -- imo -- unnecessary.  For a system with 6 GB of memory and running only Apache, without SQL or other things running in the background, I would venture to say the usual rule-of-thumb "3 to 4 times the memory" swap space can probably be reduced to 2 to 4 GB.
papakotaAuthor Commented:
Thanks for your reply!
Who said that there's only Apache running? It's a whole LAMP stack! That's first.
Second, is that it's an Ubuntu desktop environment and I would be doing some other stuff simultaneously, like browsing the web. What does "Apache child process" mean? Does it mean unique visitor?
I was told that web server never sleeps, 'cos it must be in a listening state. What I still don't get is why the visitor can't awake it? Kinda like Wake-up on LAN feature. Or is that different...?
Dr. KlahnPrincipal Software EngineerCommented:
Apache's child processes handle requests.  Roughly speaking, each child can handle one simultaneous request.

You would need to get into a discussion of linux internals to properly discuss how Apache works and how it interacts with the pre-emptive scheduler (of which there are about six) and the linux priority scheme, which is beyond the scope of our little discussion here.  Easier to consider it as master-subordinates situation.  Apache dispatches subordinates as required, but there are always some subordinates waiting even though not active.

As a side note, I would not run LAMP on a development machine when hardware is so cheap.  Development always destabilizes computers.  A $20 Pogoplug makes a good basic Apache server and it pulls only 13 watts.  If there is more than basic Apache, something like a Neoware thin server repurposed for debian pulls only 50 watts and can take up to 512 MB.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.