Search code examples
phpsocketsscale

Need help with PHP socket server!


Hi i am writing a socket server , At the moment i have 2 options

  1. Go with PHP

  2. Go with C++


The thing i need to know is that which of them is more reliable and scalable.After searching google a lot i found out that pretty much C++ can take care of my Scale needs but the thing is C++ requires much more coding then PHP moreover deployment is a bit harder on C++ .

PHP sounds promising (because of native API's for SQL & SOCKETS also its easier to deploy on cross platforms ) but I have no clue on how scalable the PHP based server can be.At the moment i want to support atleast 1k - 2k concurrent connections . Can PHP take this load ?

Also is there any way to implement Multithreading in PHP (so that i can part the workload on 2 or more threads rather then 1 overloaded thread holding all users and there requests).


Incase needed My server is a basic machine.

Processor : AMD Sempron 3000+

RAM : 2 GB

HDD : 80 Gigs

I plan to move to a faster server after some time .

Thanks in advance.


Solution

  • PHP is definitely a bad choice - no threads - your basic architecture would be to fork() a process for every connection. Not fun.

    C++ is probably the way to go, though you might other interpreted languages and evaluate them.

    Before committing to writing something in C++, I'd certainly consider an event-driven server-side-javascript approach (see http://nodejs.org), or possibly something python (twisted?) or ruby-based.