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
https://forums.phpfreaks.com/topic/234285-forwarding-http-post/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.