0

We have an message sending application, to send message it need to trigger an url for every message.

We have a database with messages, an application daemon picks first 100 messages from database, triggers the urls in loop and deletes the message from database. It is a continuous process picks 100, sends and deletes.

I am using CURL to hit the urls, but i am not able to achieve much speed.

Please provide me any alternative process to trigger at-least 1000 urls for sec.

Note : i don't need to wait for response from url

Thanks in advance.

sankar.suda
  • 1,097
  • 3
  • 13
  • 26

1 Answers1

0

I'd suggest you write your own trigger method using PHP Sockets. There's even some sample code on the page that looks adaptable to your needs:

/* Get the port for the WWW service. */
$service_port = getservbyname('www', 'tcp');

/* Get the IP address for the target host. */
$address = gethostbyname('www.example.com');

/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
    echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
} else {
    echo "OK.\n";
}

echo "Attempting to connect to '$address' on port '$service_port'...";
$result = socket_connect($socket, $address, $service_port);
if ($result === false) {
    echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n";
} else {
    echo "OK.\n";
}

$in = "HEAD / HTTP/1.1\r\n";
$in .= "Host: www.example.com\r\n";
$in .= "Connection: Close\r\n\r\n";
$out = '';

echo "Sending HTTP HEAD request...";
socket_write($socket, $in, strlen($in));
echo "OK.\n";

As far as 1000 URLS per second... eh, good luck with that. You may want to have multiple copies of your daemon running at the same time with different portions of the task queue loaded in order to get the kind of parallelism you need.

Winfield Trail
  • 5,535
  • 2
  • 27
  • 43