4 ms·
> PHP iirc can't even be used as a websocket server True, if you run it behind a web server like 99.999% of all users. If you run it as a cli script, you can
by geon 10y ago
> PHP iirc can't even be used as a websocket server
True, if you run it behind a web server like 99.999% of all users.
If you run it as a cli script, you can implement pretty much anything. I saw a ftp server once. Crazy.
Still, even on a normal web server, php can do long polling perfectly fine, which is often enough.
> being able to write program flows without dozens of promises is a breeze
It is a breeze with async/await too.
- LinuxFreedom 10y agowhat would be a good hardware spec and server configuration to have 5000 users do long polling with a php backend?
- geon 10y agoIf you care about performance and traffic, perhaps php isn't where you should start anyway.
- mschuster91 10y agoUh. You do realize that Mediawiki, powering nearly all wiki systems including Wikipedia, is written in PHP. Or Facebook, they were able to go with PHP for iirc 500 M users? PHP is in any case a better choice, performance-wise, than Python or, god forbid, Java.
- cutler 10y agoPHP performs better than Java? Care to offer evidence?
- mschuster91 10y agoCan't disclose much in public, but our PHP CMS hosting requirements tend to be waaaay cheaper than our Java-based CMSes. Also, deployment of PHP apps is (in my experience) faster and easier.
- cutler 10y ago(cheaper hosting || faster deployment) != better performance
- geon 10y agoFacebook built their own PHP-to-C++ compiler (https://en.wikipedia.org/wiki/HipHop_for_PHP https://en.wikipedia.org/wiki/HipHop_for_PHP) and later a JIT compiler/VM (https://en.wikipedia.org/wiki/HipHop_Virtual_Machine https://en.wikipedia.org/wiki/HipHop_Virtual_Machine), with a custom, typed version of PHP (https://en.wikipedia.org/wiki/Hack_(programming_language) https://en.wikipedia.org/wiki/Hack_(programming_language) ). All just to make PHP a little faster. I think you are making my case.
- mschuster91 10y agoHH transpilation was introduced in 2010. Depending on when exactly you look in 2010, FB had between 350-600M active users (https://www.yahoo.com/news/number-active-users-facebook-over-230449748.html https://www.yahoo.com/news/number-active-users-facebook-over...). Many websites don't ever get to 350M users, so it's safe to say that plain PHP will satisfy your startup for a long time. Also, PHP7 is pretty much on par with HHVM in real-world scenarios: https://kinsta.com/blog/the-definitive-php-7-final-version-hhvm-benchmark/ https://kinsta.com/blog/the-definitive-php-7-final-version-h...
- geon 10y agoAnd the vast majority of websites never get 5000 concurrent users either. Your planned load obviously dictates the language as much as anything else.
- SergeAx 10y agoCheck out "experimental JIT branch" of PHP. It boost performance 1.5-2 times compared to current PHP 7.1, and they didn't start optimization yet. It blows HHVM out of the water, and I can't wait to compare performance with Java and .NET.
- LinuxFreedom 10y agoYes, of course there are easy to use and much better programming languages for that - I just really wanted to read some "real-life" recommendations from that guy that mentioned "php" and "long-polling" in the same sentence. [Maybe it was just a joke and I did not get it... or I did get it but did not identify it as a joke... however... I would like to see some beef...]
- mschuster91 10y ago> If you run it as a cli script, you can implement pretty much anything. I saw a ftp server once. Crazy. Yeah, I implemented a simple ircd once. Funny days... but I don't know of any library/framework that could help you with the websocket protocol level, and I'm too old for writing my own ;)
- geon 10y agoWebsocket is actually not that complicated. A couple of headers to upgrade the request from HTTP to websocket, then framing of each payload. But you could use something like websocketd, which spawns a process of your chioce for each client and pipes the websocket to stdin and vice versa. https://github.com/joewalnes/websocketd https://github.com/joewalnes/websocketd Each PHP process looks like it takes about 5 MB of ram on my laptop, so probably not the best method for 5000+ concurrent users if you use PHP, but still.
- cr0sh 10y ago> I don't know of any library/framework that could help you with the websocket protocol level FYI - http://socketo.me/ http://socketo.me/