Thread: Redirecting POST request from one server to another

  1. #1
    Registered User MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    183

    Lightbulb Redirecting POST request from one server to another

    Hello,


    I try to come up with a good solution to this problem: user sends a POST request to a server one, lets call him "master server", this server compute the request and base on results either accept the request or pass it to other server "satelite server ". Example, User sends POST request which is 200 Mb file to master server, but since that server has no enough HDD space decide to redirect that request to server "2".
    The question is how to achieve it technicaly. The solution in which master server takes the whole POST request and then resend it further is bad idea. It is also important that the whole redirect process should be invisible to the user, so in example when user sends that request to example.com he should remain on that domain to the end of the job.
    I am looking forward for your idea guys


    Thanks in advance!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,560
    This sounds like a reverse proxy. Perhaps reading up on that concept will help.

    Quote Originally Posted by MartinR
    The solution in which master server takes the whole POST request and then resend it further is bad idea.
    Why?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    183
    Quote Originally Posted by laserlight View Post
    This sounds like a reverse proxy. Perhaps reading up on that concept will help.
    But would I be able to compute initial request ?
    And as for question why not send it twice - I think its obvious, do something twice tells everything about that solution

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,560
    Quote Originally Posted by MartinR
    But would I be able to compute initial request ?
    I suggest that you avoid saying "I" without clarifying what role you are assuming in asking that question.

    Quote Originally Posted by MartinR
    And as for question why not send it twice - I think its obvious, do something twice tells everything about that solution
    No, you are only doing it once: the server proxying to the other server was unable to complete the request on its own as it figured out that there was not enough resources to do so, i.e., it is the other server that handles the payload and returns a response that the reverse proxy then passes to the client as if the reverse proxy did the work.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,758
    Is this a form of load balancing?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    183
    Quote Originally Posted by laserlight View Post
    I suggest that you avoid saying "I" without clarifying what role you are assuming in asking that question.
    "I" as a programmer, server admin the man responsible for it
    Quote Originally Posted by laserlight View Post
    No, you are only doing it once: the server proxying to the other server was unable to complete the request on its own as it figured out that there was not enough resources to do so, i.e., it is the other server that handles the payload and returns a response that the reverse proxy then passes to the client as if the reverse proxy did the work.
    Hmm I think it's what I should do but the question is: how to technically redirect that request, and get response back ?

    Quote Originally Posted by Salem View Post
    Is this a form of load balancing?
    Yes, kind of.

  7. #7
    Registered User MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    183
    Ok i solved it

  8. #8
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,980
    What about the poor sap in the future that has to accomplish the exact thing - then searches and finds this thread?

    gg

  9. #9
    Registered User MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    183
    Quote Originally Posted by Codeplug View Post
    What about the poor sap in the future that has to accomplish the exact thing - then searches and finds this thread?
    gg
    Well, you are right, but in this case describing the solution is almost imposible since it is very much platform/application dependant. If anybody is interested feel free to participate in subject.

  10. #10
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,980
    I guess the poor sap is SOL - or will have to revive an old thread, and hope you haven't gone and taken your secrets with you.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need a post removed at request of the school
    By Cody Filion in forum General Discussions
    Replies: 7
    Last Post: 04-09-2015, 01:44 PM
  2. HTTP POST Request trouble
    By omalee in forum C++ Programming
    Replies: 1
    Last Post: 04-22-2014, 08:40 PM
  3. HTTP GET and POST REQUEST
    By strickey in forum Networking/Device Communication
    Replies: 3
    Last Post: 04-20-2007, 04:23 PM