4 ms·
> PHP is considered extremely weak performance-wise I don't know, it seems a lot of the very high trafficked sites (Facebook, Yahoo) run PHP. Yes benchmarks d
by wvenable 17y ago
> PHP is considered extremely weak performance-wise
I don't know, it seems a lot of the very high trafficked sites (Facebook, Yahoo) run PHP. Yes benchmarks do show PHP doing poorly, but when was the last time anyone used PHP to crunch numbers? It's apparently fast at what it needs to be fast for.
> There is poor to no support of multithreading
That is not a flaw. PHP is a share nothing architecture; each request is completely independent. This is a good match for the stateless nature of HTTP. Multithreading isn't at all appropriate for PHP and I can't think of a scenario where it would be needed.
> There is no eventing system
PHP is a programming language not a framework. I'd make more of a comment about the various PHP frameworks but "eventing system" seems kind of vague. Maybe you can clarify this a bit and then I'll comment.
> As a web framework, it sins in mixing code & design (opposed to e.g. Django-Python or Ruby on Rails)
Nobody mixes in code & design in PHP anymore -- you won't find it terribly common among the various PHP frameworks. I do use it from time to time as a debugging aid and my compiling template engine uses it as the compilation target.
- shmichael 17y ago> I don't know, it seems a lot of the very high trafficked sites (Facebook, Yahoo) run PHP I'm completely for PHP as a simple and accessible language. The previous author wanted to hear about the shortcomings of PHP and I tried to provide some. PHP sites such as Wikipedia probably need more servers (since every request is a separate process). They might be saving a lot of manpower by using PHP, so it might be an OK tradeoff. By the way, Facebook uses Erlang for its performance-critical parts (such as chat). > PHP is a share nothing architecture; each request is completely independent. You could still use an agent-like messaging system for shared-nothing multithreaded/multiprocessed environment. > I'd make more of a comment about the various PHP frameworks but "eventing system" seems kind of vague. Maybe you can clarify this a bit and then I'll comment. e.g. When using cURL you must poll the handler until the request is complete. Obviously you'd need multithreading to achieve a better control flow in such a scenario. > Nobody mixes in code & design in PHP anymore I've written and debugged some wordpress plugins, and I can't say I came to the same conclusion as you...
- wvenable 17y ago> PHP sites such as Wikipedia probably need more servers (since every request is a separate process). Citation needed. But every request isn't a separate PHP process; PHP is linked into Apache. Apache starts up a pool of processes and reuses them for requests. It's all highly efficient. > By the way, Facebook uses Erlang for its performance-critical parts (such as chat). Actually, it's not so much the performance critical parts but the parts where PHP's share-nothing architecture isn't appropriate. I doubt they're using a front-end web server for chat either. > You could still use an agent-like messaging system for shared-nothing multithreaded/multiprocessed environment. If you had the need, I suppose you could. Although I'm not sure what point you're trying to make here. > When using cURL you must poll the handler until the request is complete. Obviously you'd need multithreading to achieve a better control flow in such a scenario. You don't really need multithreading. JavaScript has callbacks for everything, for example, but isn't multithreaded. So this isn't so much a problem with PHP as it is a lack of design of cURL. But then cURL is a C library. > I've written and debugged some wordpress plugins, and I can't say I came to the same conclusion as you... Wordpress is old and not well designed. (Much like PHP itself)
- jrockway 17y agoYou don't really need multithreading. It's true; many languages allow you to handle concurrent downloads by letting the OS call a function when the socket with the data is readable. (This is part of an "event loop".) Many language implementations call this threading, however, because it is. You don't need one heavyweight OS thread for every thread of control in your application; many applications that make heavy use of IO easily handle thousands of threads inside one OS thread. It's a very useful abstraction.
- shmichael 17y agoApache starts up a pool of processes and reuses them for requests. It's all highly efficient. It's highly efficient if you have a small number of requests at any given time; It's not as efficient for peak hours. If you had the need, I suppose you could. Although I'm not sure what point you're trying to make here. There are several use-cases I can think of, the simplest being more than one blocking request for rendering your page, and using multi-process to reduce the latency to the maximal block time instead of the sum of all block times. You don't really need multithreading. JavaScript has callbacks for everything, for example, but isn't multithreaded. So this isn't so much a problem with PHP as it is a lack of design of cURL. But then cURL is a C library. Javascript on server environments needs solutions such as node.js. On the client side, well, most UI apps have a single UI thread and delegate jobs to worker threads. In javascript, these are usually done via XMLHttpRequests.
- jrockway 17y agoMultithreading isn't at all appropriate for PHP and I can't think of a scenario where it would be needed. Not blocking the entire PHP process while waiting for database results, waiting for a file to download, waiting for memcached to respond, etc. I would (and do) use an event loop for this sort of things, but lightweight threads are technically a better abstraction. Web apps would use a lot less memory (and hardware) if people were not so afraid of threads. (This happens a lot; a bad implementation of something taints the whole category. pthreads, Java threads, Perl ithreads, etc., are broken, so all threading is bad. C++'s object model is bad, so all object oriented programming is bad. It's sad.) BTW: some good thread implementations include Haskell's and Perl's Coro.
- deleted 17y ago[deleted]
- wvenable 17y ago> Not blocking the entire PHP process while waiting for database results, waiting for a file to download, waiting for memcached to respond, etc. The thing is, I need those database results -- I can't do anything else until I have them. I received a single request from the user and I'm spitting out a single HTML response back. That's what PHP is all about. And mulithreading as optimization itself wouldn't improve performance because I'd be taking away CPU from other requests that are running concurrently. > Web apps would use a lot less memory (and hardware) if people were not so afraid of threads. Fundamentally I don't disagree; there's a lot of cool work going with event-based web servers. However, I think those designs are great for very specific tasks like chat servers and but require too much fiddling when doing traditional stateless web work. However, it may indeed be the future.
- jrockway 17y agoThe thing is, I need those database results -- I can't do anything else until I have them. You could start requesting the database results for a user that is now waiting in the tcp connect queue, cutting latency significantly. Most people handle this with load balancing between processes, but your blocked-for-DB-results-process is sitting idle using system resources, like memory. If you only have one user using your site at a time, then this isn't a concern. But for everyone else, blocked processes are wasteful. but require too much fiddling when doing traditional stateless web work Well, yeah, because you don't have threads. When you do, everything is handled by libraries for you; you can think you're blocking, but actually not block the process.