Reputation: 9491
I cannot figure out for the life of me the purpose of an application like Cometd or simple-comet over something like a simple longpolling request with php and an infinite loop with code like so
$time = time();
while(time() - $time < 30) {
if ($query) {
$shapes = ...;
echo json_encode($shapes);
break;
}
usleep(25000);
}
running on a webserver that is designed for multiple requests, like lighttpd or NGIX.
maybe I am just miss understanding the documentation of comet services. I know the above is a "Comet" request but why do things like cometd exist, what do they do better.
Upvotes: 3
Views: 488
Reputation: 18261
Cometd and similar software like orbitd are great for breaking up area's of responsibility. I can have my lighttpd backed python services focus on doing more involved work while the comet service is tied to a message queue to handle light message notifications (ex batch request is finished, you've got a new message, etc ) while the lighttpd servers handle DB requests or process POST/PUT/DELETE requests.
Last point, Apache is still a very popular web server but it will die in a blaze of glory if it tries to hold a thousand or more connections open. For a platform with an array of apache servers that wants to add comet support, it would make sense to go with an out of the box solution versus rolling one with lighttpd or nginx.
Upvotes: 1