6 ms·
PHP, for all its faults, enjoys one advantage over, basically, everything else: SCALE. People have figured out how to build dead cheap mass hosting in PHP. Yo
by mschuster91 11y ago
PHP, for all its faults, enjoys one advantage over, basically, everything else: SCALE.
People have figured out how to build dead cheap mass hosting in PHP.
You can support next to infinite numbers of small projects on a single apache+mod_php server - as long as they don't get many visitors you're fine.
NodeJS, Java or other hipster languages will require one instance of a runtime for each project that runs.
Also, the problems of how to host and develop PHP project have been solved - for a hoster it's usually enough to tell people "here's your ftp, here's your mysql access data, have fun". No other environment (except static HTML of course) comes anywhere close to that.
- lotyrin 11y agoScalable but slow. CGI model of execution and everything being synchronous throws away too much effort that could have been shared between requests or spread across CPU cores. Best case scenario, you have to tie your app in knots and come up with arcane cache keying/invalidation strategies to be able to cache exactly the right things, then you still have to make multiple round-trips to a cache service per page (unless every page is identical or every page is entirely unique), and PHP just twiddles its thumbs waiting on the network for each one, one after the other.
- icebraining 11y agoNo, Java web application servers like Tomcat can run multiple sites/apps on a single instance of the JVM.
- iofj 11y agoSince I know that's actually true, why are there so few hosters actually doing that ? I mean, I get that there's no money in it for Oracle, so it's certainly not a priority for them, but still, it should work.
- StreamBright 11y agoNodeJS and Java as hipster languages? I think there is a lot of enterprise effort put into those VMs to make the code execution fast behind those "languages", more like programming environments. PHP does not have any advantage over Java or even NodeJS as far as language syntax goes, but it offers less in terms of instrumentation and other much needed features of making production ready code.
- untitaker_ 11y agoCGI is not unique to PHP and is available for most interpreted languages. In Python I can wrap any WSGI app in CGIHandler from Python's stdlib and it just works.
- lukeschlather 11y agoMost of the cheap mass hosts support basically everything else in addition to PHP. The world where shared hosting only supported PHP ended quite some time ago.
- aikah 11y ago> Most of the cheap mass hosts support basically everything else in addition to PHP But PHP requires very little configuration on cheap hosting. At most, tweaking an HTACCESS file. The only competition in this space is Python (Django,Flask and co work with mod_wsgi). Cheap PHP hosting providers are basically PaaS (Apache,PHP,Mysql...) which is a good thing and a bad thing ( no flexibility, stuck with a PHP version). Good luck running Rails or Spring on cheap shared servers. On a $2 PHP/Python shared host I can virtually host as many apps as I want. Because of memory requirements upfront, I can't do that with Rails, or Spring. Because most mass shared hosting providers do no allow long running processes even NodeJS is out of question.
- Kiro 11y agoWhat is that concept called? What other languages support it? (The fact that PHP doesn't require an instance of a runtime.)
- CaveTech 11y agoPHP does have a runtime, but the overhead is fairly low. It's a concept shared with many other scripting languages.
- Kiro 11y agoBut surely it isn't the same kind of runtime as for example Node.js, where the script is persistent whereas PHP runs it clean from the start every time?
- lotyrin 11y agoCGI. Any language can do it. Language runtimes that have long startup times or don't cache the output of any of their compilation steps are less suited though. A binary or script gets called with environment variables providing info about the request (e.g. query parameters), standard in contains the request headers and body. You can provide headers and response body via standard out. RAM and CPU usage when your site has no traffic = 0. Running a bunch of this kind of site on a single web server becomes extremely economical. (In the sense that disposable cutlery and 99 cent cheeseburgers are economical.) This side of 1999, it's worth it to have a few tens of megabytes of application code resident in ram to shortcut start up times. Instead of having each page start its own process, multi-threaded apps running on highly parallel hardware allows you to share effort between requests without bothering with cache coordination (or waiting on round-trips to the cache service). The benefit of faster page loads (higher conversion rates, happier readers, etc.). Since the age of CGI, moore's law and disintermediation has made these things cost less than a child's allowance.
- tyingq 11y agoJust making sure this isn't misinterpreted as saying that people run PHP (or really anything) on the old, traditional CGI model that forks a new process for each invocation of a script. Most php installations are either mod_php, running within the Apache process itself, or via fastcgi. In either case, the processes are pre-started and pooled.
- ninjakeyboard 11y ago"Scale" doesn't mean being able to run many applications on a server - it means being able to serve a lot of traffic. Dynamic languages are inherently slower and one thread per request server models tend to perform poorly once they hit a certain concurrency threshold because the cost of creating/destroying and context switching between threads becomes pretty high. The reason people talk about node being performant is because it uses a small number of threads with event driven approaches (well, one thread in Javascript itself.) You'll see a lot of the modern approaches use event driven approaches (Typesafe/Play/Akka/Scala, node, nginx etc) because they handle high levels of concurrency much better than one-thread-per-request models of yester-year. The issue isn't so much one thread per request models as much as it is waiting around for database access etc. Once threads are parked and sleeping, performance will really suffer at scale. Any use case where you have to read from remote datastores will like topple over pretty quickly or else be very expensive to scale if you're using PHP. The blocking thread-per-request model really doesn't scale very well.
- deleted 11y ago[deleted]
- tyingq 11y agoThis makes sense, but isn't really about PHP at all. You're comparing node.js, with it's built-in event driven web server to ANY language running in a fastcgi or mod_xxx fashion. Python, perl, etc, running under fastcgi would all have the same downsides you are citing. You can, for example, use Facebook's HHVM+Proxygen to serve up event driven PHP. That would be a more direct comparison to node.
- jorgecurio 11y agoBack in university, I used to run a porn site on one of these free Apache based 'Unlimited' hosting. Needlessly to say, I have to agree with you, it did do a quite a bit of traffic: 250gb but began to struggle once the concurrency reached past 40 users. I remember logged into ssh, monitoring when the site would go down so I could restart the Apache server (wasn't aware of upstart and other techniques back then all I knew was how to jack nulled PHP scripts, upload it on free hosting, and spam forums to get people to jerk off to Japanese porno tube. Nevertheless, I made small monthly income to pay for cigarettes and food through university thanks to Apache and cheap cheap 'Unlimited' hosting. I eventually bought a huge $100/month server back in 2009 and that's when things started going south ad revenues started to fall for the adult industry.
- fluxquanta 11y agoOff topic a bit, but it's interesting to hear your perspective on this. Everyone always says "Porn is 90% of the internet" but you never seem to hear from the developers who actually run the sites. Is it shame from being associated with something that people may find "immoral" that keeps these devs quiet? I would really be curious to hear more about developers who work in this field, especially for the big -tube sites.
- jorgecurio 11y agohaha sure I can throw my 2 cents in here. I don't think they are ashamed but they hang out at places like gfy.com, a cesspool of adult site owners and affiliate marketers, who ironically are hostile towards tube sites as 'stealing content'. Then one spring afternoon in 2008, I was pondering what I'm going to do for money while sitting around campus then it just hit me that the fastest way to get traffic therefore more money was porn. I did have some qualms particularly because it felt like I was doing something...that might be looked down upon but then I thought it was pretty fucking stupid since I'm not the one making porn (although I did think about this too) so I felt like this was a good way to learn PHP&MySQL(lol) so I went for it. And it paid dividends throughout university. I heard a local guy who founded youjizz.com pulling in $100,000+ CAD /month from webcam ads but this was 2008. I think the advertisement have declined significantly since then and I've moved on to more meaningful problems to solve rather than dealing with the intracicies of delivering smut to the end user on budget web hosting. I don't know if it's worth it to make porn sites anymore. There's large tube sites that just dominate the traffic. I consider my own tube porn site to be a failure for not reaching that level of status. But boy did I spend a lot of time getting it all up and running. Equally more innovative was the spamming tools I wrote for forums and watermarking porn videos automatically via ffmpeg and uploading it to multiple websites. Actually ended up spinning off a SaaS business from that script.
- ef4 11y ago> Java or other hipster language If I had to pick the least hipster language I could think of it would be Java. Stable, favored by big slow organizations, old enough to be uncool, but not old enough to be retro. Definitely the anti-hipster language.
- mschuster91 11y agoScala, Clojure et al. and Java all share the JVM as runtime environment. With all its downsides, including ridiculous startup times and memory usage.
- takeda 11y agoJava != JVM, Java doesn't even have to run in JVM. You should update your response then.
- njharman 11y agoPeople, maybe not you or OA, have learned how to "scale" every commonly used web dev language. Your error with that, not usiing the common definition of scale, and balls ludicrous assertion that the most, big E Enterprisey language is hipster obliterates your credibility on the subject.