开发者

POST form data redirection to another server depending upon post variable

I have a feedback form on server A. Due to heavy traffic I want to redirect some of these POST requests to another server B based on the category of feedback (a field in the post form).

The problem is the feedback form is distributed across multiple mobile applications and is hard-coded now. We cannot change anything in the Form post now.

What is the best approach? 开发者_StackOverflowIs it possible to do using DNS redirection? I would ideally like that before the request reaches the Apache server to increase the load, the redirection happens. Please suggest.


You could return a 307 HTTP response, which tells the client to redirect to the other location, while re-posting all data. That could be a disadvantage for large chunks of data (files), but it will be too if you choose to send the data to the other server yourself. Besides that, the first server will receive the data anyhow, so you only gain by this solution if the processing itself is relatively costful.

An even better solution would be to use a load balancer which can determine for you which server to send the data too.


Ideally you need to change the form (not the actual form itself, but supporting code). The idea is to add some JavaScript, that upon submitting a form checks that "category" field and changes the value of form's "action" attribute making it submitted to a desired server.

If that is cannot be done at all (for whatever reason), then this may be implemented on server side. Instead of hitting Server A directly, it should hit Server Zero -- a load balancer, which then can route the request further based on the logic you provide: e.g. 1) choose less busy server; 2) randomly choose server; 3) analyse POST form data and choose right server; 4) other options. #2 can be implemented via DNS (an example is available in the link below).

Any load balancer should be able to implement options 1 & 2. For other options you have to check if specific load balancer (software or hardware) supports it (check feature list).

Links:

  • http://en.wikipedia.org/wiki/Load_balancer
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜