Hacker News new | ask | show | jobs
by jqpabc123 8 days ago
55–73% of nginx throughput on static files

So it is not really a competitive option for serious use.

2 comments

Not sure I follow. Many webservers have 55% or less of nginx throughput. NGinx is written in C, the fact that you can even achieve over half its throughput in PHP for static files is pretty incredible to me.

This server is not competing with nginx for serving static files. It's competing with nginx+php-fpm for serving PHP, and there, it wins by a large margin.

You might have a very narrow definition of "serious use". This isn't just for people who want to serve static files. This is for people who want to host PHP applications without having to manually install nginx, configure its proxy_pass to php-fpm, etc.

In some ways, in real-world scenarios, this server would actually be faster than nginx with php-fpm. Because it can prefork processes after it has loaded classes, so all that bootstrapping your PHP scripts do having to load classes over and over, (even with PHP's opcode caching) can be on the order of tens of milliseconds. That's saved per call.

You can still put nginx in front of this, by the way, for much faster https. But you can also put CloudFlare, CloudFront, or any other CDN in front of it instead, and get all the advantages of reverse proxies, etc.

But, all by itself, this server handles reverse proxy, caching (including Cache-Control headers, ETags, etc.) and, very importantly, it allows your PHP to do two things that other webservers don't:

1. Send X-Accel-Redirect headers in order to enforce true access control for static files, based on cookies etc. Gone are the days you have to host files publicly at unguessable URLs, that people can share with others.

2. Send X-Cache-... headers that actually let the server cache parts of the page rather than the whole page. When you invalidate one thing, it intelligently invalidates all the pages that transitively depend on that thing.

There's a lot more to it. You commented 2 minutes after it was posted, so I imagine you haven't actually read the README. Go and read it. Yes, it's for "serious use."

Was absolutely ready to point you out how this is a fun side project nothing serious just to show its possible, then I read the readme and wtf it does not seems like it?

Just use frankenphp and be done with it, it runs caddy, doesn't need an external php runtime and also lets you bundle your app as a single executable.

FrankenPHP uses Go. This is pure userland PHP. No other dependencies.

For one thing, developers who actually code in PHP need a web server. This "just works" out of the box. No need to install Go, or Nginx, or php-fpm, or configure proxy_pass, or certificates, etc. etc. Yes, caddy also handles certificates, but what about the rest?

There is a section in the README comparing this to FrankenPHP, Swoole, etc. You can see where this approach actually beats them. In fact, instead of simply declaring "it sux", why not try it first? It takes 5 minutes. Download and launch.

And a word about about safety. FrankenPHP workers persist between requests, which means every static variable, singleton, and global cache in your app -- and every library you use -- becomes a potential data leak between users. Qbix Server gives you the same performance benefit (zero bootstrap cost) via fork-after-preload, but each request gets its own process. When it's done, everything is gone. No audit needed.

Go is not a dependency. Go is a compiled language, once you download the frankenphp binary you do not need anything else, whereas you still need php for yours.

The readme is fully ai generated so its not a great start, but I checked anyway and yes the only thing I agree with is the lack of X-Accel-Redirect which really bother me.

I know about safety I'm literally in the process at work of going through our app to check for this exact issue since we are moving to frankenphp. And it's quite easy, unless you did something REALLY WRONG in your app, it's just a matter of implementing the ResetInterface [0]

[0]: https://github.com/symfony/contracts/blob/main/Service/Reset...

It’s quite ironic that you are pointing out I still need PHP to run … PHP. Whereas if I download a Go binary, then I won’t.

Well, I can do you one better — you can compile the entire server and PHP code to a binary, as it says in the README, so you won’t need ANYTHING once you download that LOL.

Also, since you wrote that comment, I also added supports for websockets (wire-compatible with socket.io) and rooms, all of it with the same approach: put files in folders and it “just works”. What is so bad about that?

You are really putting bad faith and being stubborn.

Yes you will need SOMETHING since you have to get your thing someway to compile this executable. Just as you'd need frankenphp to compile a single binary just as you that will then not require anything.

Great, it's a good thing to have websocket support it's clearly lacking in the php world.