Forwarding Requests to Multiple Upstream Servers?

Igor Clark igor at pokelondon.com
Wed Jul 9 13:58:56 MSD 2008


Hi there,

Somewhat off-topic for nginx, but I'm really interested to hear more  
about this. I recently tried this out by sharing a PHP code base  
between 2 application servers over NFS, NFS server on app server 1 and  
client on app server 2. I found that as soon as I added app server 2  
(nfs client) into the nginx upstream list, the load on the app server  
immediately and dramatically increased. I assumed it was something to  
do with insufficiently aggressive NFS caching and tried various tweaks  
on the mount and export options including the sync settings, but it  
didn't really make any difference. When I switched the app server 2 to  
use local PHP files instead, the load dropped immediately.

Our application was built on our PHP framework which uses a lot of  
include files, hence we were using APC opcode cache to minimise  
interpreter time. I guessed these factors might have been big  
contributors to the load as PHP would have been checking modification  
times on a lot of files, and then APC was probably doing more checks.

Do you (or anyone) have any thoughts on whether what I was doing just  
isn't well suited to NFS sharing, whether it was possibly related to  
the caching stuff, or whether if I'd been able to spend more time  
tuning the NFS configuration I might have been able to get lower CPU  
usage? I do seem to hear of people doing what I wanted to do  
(obviously it's better to have the code in one place and not have to  
update in multiple places if possible) so I'm sure there must be ways  
to get it to work; quite possibly my NFS configuration was naïve ...

Thanks,
Igor

On 9 Jul 2008, at 10:08, Tit Petric wrote:

> Does nginx support forwarding specific request types (POST request  
> only for example), to a specific backend?
>
> Handling file propagation from one "master" backend to the other  
> nodes would be easier than to have it come to a random backend.
>
> For the original poster, I would recommend using a NFS server to  
> share files between the various backends. Keep in mind that NFS  
> would be slower than a local file system, so I would advise keeping  
> a file&directory index in the database, to avoid some basic  
> problems. As far as reading and writing files goes, I've had very  
> little problems over the years with a setup that uses NFS extensively.
>
> Best regards,
> Tit
>
> Igor Sysoev wrote:
>> On Wed, Jul 09, 2008 at 09:15:25AM +0200, Sven C. Koehler wrote:
>>
>>
>>> I am wondering whether it's possible from within an nginx module to
>>> forward a request to multiple upstream servers....  AFAIU nginx's
>>> existing infrastructure does normally only support sending  
>>> requests to
>>> one upstream server.  In my example I'd like to update data that  
>>> resides
>>> on multiple servers if it's a POST request and want to send back  
>>> only the
>>> response of the first upstream server.
>>>
>>
>> No, nginx does not support it.
>>
>>
>>









More information about the nginx mailing list