Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

we have a website with CometChat integration for our users; since our apache server gets a lot of requests for the chat service, we'd like to set a different (lower) priority for these requests, while serving with an higher priority the other ones.

As far as we know, one way to do this could be using mod_qos, that would let us limit the number of requests in a period of time (eg reqs per second) for a specific path. This is not exactly what we'd like to do, but could be a partial solution.

My question is: is there a better solution to prioritize requests? If you suggest to use mod_qos, which would be a good configuration for mod_qos to achieve what I asked?

Thanks

share|improve this question
    
what resources are you running out of? CPU? Memory? Network? –  The Unix Janitor Jul 19 '12 at 15:27
    
CPU. ATM the situation is not that bad, but we're trying to optimize our conf to be prepared as connections grow. We use mainly php code on apache (prefork). –  lorenzo.marcon Jul 19 '12 at 15:33
    
In that case you should start using something from this century! Switch to apache 2.2 or 2.4 and use the worker or event MPM proxied to a PHP or FPM backend. –  adaptr Jul 20 '12 at 7:48
    
.. we ARE actually using apache 2.2. we use prefork to be safe with php modules. look at the big red warning on php manual here php.net/manual/en/install.unix.apache2.php - btw, we're switching to php-fpm on our dev server, then we'll get it on our prod server too. –  lorenzo.marcon Jul 20 '12 at 8:21
add comment

2 Answers

It is not possible to prioritize requests within the apache web server directly.

That said, since apache contains a complete proxying and loadbalancing solution out of the box, there are lots of tweaks to be made with that.

You should probably look into proxying to separate backends (that can run on the same server) using ProxyPass

This would separate the requests for the chat service from other requests, and you can then decide on a proxy-by-proxy basis how much resources each backend has available to answer requests.

A full solution would be outside the scope of this format, but the apache documentation for mod_proxy will get you started; especially look into the ProxyPass options that allow you to set priorities and request limits per-backend.

share|improve this answer
add comment

If you've got distinct services that you are offering, and you are CPU bound then options are

1) Scale up (bigger machine , 8 CPU cores or more!)

2) Scale out - Once you reach the limit of scaling up one machine, scale out, Multiple machines with a load balanced solution - Gives fault tolerance as a free positive side effect.

Things to think about:

Separation of services . Run your chat and web services on different machines or clusters

Optimise your platform, use an efficient solution. Think about caching requests/front end proxies.

Okay, bringing your comment on board. The only other way i can think it could be done is

run two instances of httpd (say one on 8000 (chat) and the other on 8001 (web) )

run a high speed reverse proxy like nginx on port 80.

set one of your httpd instances to a lower priority.

Tune your http configuration.

share|improve this answer
    
thanks for your answer, we have a 8 core server, and we're not exactly running out of cpu, we just have some peaks when the load is pretty high, and the website slows down. Of course a very good choice would be the separation of services (e.g. chat in another server), but at the moment we think this server should be enough - with the right confirguration, of course. –  lorenzo.marcon Jul 20 '12 at 10:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.