Scala or Python to Build a Comet server to support a PHP application?

Problem

I have a currently running PHP application that I want to add real-time feed (Google search latest result feeds), I have an implementation in PHP that does the following:

  1. An AJAX request to the server.
  2. The PHP responds.
  3. After 15000ms (15 seconds) using setTimeout(), we repeat the steps.

I knew this have very much overhead on the server and will cause the C10K problems.

After researching I figured out that PHP as an Apache2 module is incompetent to implement the Comet solutions which is unfortunate!

I have two options, to use Scala, or Use Python to implement this part of my website since it’s all complete and there is no time for rewriting it.

I don’t care for anything as I care for performance since I use VPS200 from ServerGrove, And I’m going to install JVM or Python side-by-side with PHP.

So what you think has less memory/CPU consumption in this case JVM with Scala, Or Python?

Thanks in advance

Update: I guess I’ll use Akka Project, I’m going to test it.

Update 2: I’ve done it using Node.js, it’s incomparable by any other solution (IMO) in learning curve, community support, and project maturity. And I had an unfortunate experience with Scala since I a gave Scala a very long opportunity before trying Node.js.

Problem courtesy of: OmarIthawi

Solution

Why not node.js? It has a proven reputation of the solution that perfectly handles COMET. Everyone knows Plurk success story — one of the most popular social networking sites in Asia that has 500+mln subscribers, with up to 200k of them working in a parallel (using COMET long-polling connections). node.js memory usage is way better (~10 times less) compared to solutions based on java app server suitable for COMET (Jetty/Netty)

 If you finally want to go with Java/Scala, you should first of all have a look at Atmosphere framework. It has the richest feature-set these days (supports all kinds of COMET strategies + web-sockets + servlets 3.0); out-of-the-box REST-support, based on Jersey (implementation of JAX-RS specification); integration with Akka (very powerful implementation of actors, fault-tolerance, STM, remotings etc on Scala). 

 Choosing a Lift, you’d probably have to re-write your application entirely, though it has a very good COMET support.

Solution courtesy of: Vasil Remeniuk

View additional discussion.

Show your support

Clapping shows how much you appreciated Jamie Munro’s story.