Jump to content

Forwarding HTTP Post


mjkemp21

Recommended Posts

Some background we are creating a system that collects rain data from multiple sensors and then every 15 mins sends a packet to the main server.  I have been ingesting this data fine and storing the info into my database and storing a local .txt file of the packet.  To forward this packet to our back up server I have been using:

 

shell_exec("nc backup_server_address < ".$my_p);

 

Where $my_p is the location of the .txt file.  However, I have been requested to not use nc as it creates its own process every time it is called and for scalability issues we would like to forward the packet using PHP and not require a new process every time we receive a packet.  I tried do some redirect stuff using headers("Location: backup_server_address").  If anyone can help that would be greatly appreciated.

 

 

Link to comment
Share on other sites

Another option would be to do a curl request from php, posting the data to the backup server.  Then you avoid a new process, but you still make a new tcp connection each time.  If you have a huge amount of traffic you might consider keeping a single tcp connection open constantly, or sending the data over udp (over a reliable local network).

 

It all depends on how much you need to scale really.  Each successive optimization is more complex.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.