News for hackers. Stuff that matters.
Re:Show HN: A Better Log Service by that_guy_iain on Saturday January 11, 2025 @10:14AM (#42666393)
This looks very interesting!

My suggestion for the self-hosting is to create docker images and use docker-compose. The self-hosting currently is a bit of effort to setup.

I also wonder if PHP is a good language for this. For the UI, yea that's fine and makes sense. But for the log processor that's going to need to handle a high throughput which PHP just isn't good at. For the same resources, you can have Go doing thousands of requests per second vs PHP doing hundreds of requests per second.

Re:Show HN: A Better Log Service by hipadev23 on Saturday January 11, 2025 @11:39AM (#42666986)
> PHP doing hundreds of requests per second.

You may want to update your understanding of PHP and Go's speed . Both of your estimates are off by a couple orders of magnitude on commodity hardware. There are also numerous ways to make PHP extremely fast today (e.g. swoole, ngx_php, or frankenphp) instead of the 1999 best practice of apache with mod_php.

Go is absolutely an excellent choice, but your opinion on PHP is quite dated. Here are benchmarks for numerous Go (green) and PHP (blue) web frameworks: https://www.techempower.com/benchmarks/#hw=ph&test=fortune&s...

Re:Show HN: A Better Log Service by p_ing on Saturday January 11, 2025 @01:02PM (#42667671)
As soon as you add C#, ASP.NET Core shoots to the top of the Fortune stack.
Re:Show HN: A Better Log Service by that_guy_iain on Saturday January 11, 2025 @01:20PM (#42667821)
What you're talking about is generally not considered production-ready. While you can use these tools you will almost certainly run into problems. I know this because as an active PHP developer for over a decade I'm very much paying attention to that field of PHP.

What we see here is a classic case of benchmarks saying one thing when the reality of production code says something else.

Also, I used go as a generic example of compiled languages. But what we see is production-grade Go languages outperforming non-production-ready experimental PHP tooling.

And if we go to look at all of them https://www.techempower.com/benchmarks/#hw=ph&test=fortune&s...

We'll see that even the experimental PHP solution is 43 and being beat out by compiled languages.

Re:Show HN: A Better Log Service by Implicated on Saturday January 11, 2025 @03:47PM (#42668803)
> ... you can have Go doing thousands of requests per second vs PHP doing hundreds of requests per second.

> I know this because as an active PHP developer for over a decade I'm very much paying attention to that field of PHP.

<insert swaggyp meme here>

As an active PHP developer as well it sounds like you have no idea what you're talking about.

> While you can use these tools you will almost certainly run into problems.

Which tools are "generally not considered production-ready"? From what I'm seeing on the linked list of benchmarks...

- vanilla php - workerman - ubiquity - webman - swoole

I'd venture to bet all of these are battle tested and production ready - years ago now.

As someone who has built a handful of services that ingest data in high volume through long-running PHP processes... it's stupidly easy and bulletproof. Might not be as fast as go, but to say these libraries or tech isn't production-ready is rather naive.

Re:Show HN: A Better Log Service by that_guy_iain on Tuesday January 14, 2025 @04:43AM (#42695466)
Having read your post:

* Vanilla PHP can't read anywhere near the same RPS as the others

* Using those results in removing the ability to use a large amount of the ecosystem. While if you used the correct language you would be able to use it's entire ecosystem.

* In my opinion, if you're using workerman or Swoole you've already realised the limitations of PHP and should be using another language.

This seems like a classic case of "if all you have is a hammer everything looks like nail"

> Might not be as fast as go, but to say these libraries or tech isn't production-ready is rather naive.

This strawman argument. Firstly, you admit my original point. Secondly, those aren't the tech in question and I notice you left off the tech in question. Roadrunner, FrankenPHP, etc. All the tooling that can make your average PHP app go faster.

Re:Show HN: A Better Log Service by hipadev23 on Saturday January 11, 2025 @03:53PM (#42668845)
Nobody is suggesting PHP beats compiled. We’re arguing with you about your utter lack of expertise in the language, knowledge of the ecosystem and “production-ready” status of the many options, and your overall coding ability when it comes to PHP.
Re:Show HN: A Better Log Service by that_guy_iain on Sunday January 12, 2025 @06:23AM (#42672797)
> Nobody is suggesting PHP beats compiled.

Actually, there seems to be people arguing that.

> We’re arguing with you about your utter lack of expertise in the language, knowledge of the ecosystem and “production-ready” status of the many options, and your overall coding ability when it comes to PHP.

If you're doing that with benchmarks you're doing a shitty job. My numbers came from experience in production environments with production workloads.

Not to mention that you're talking experimental tooling as examples. I've literally seen multiple companies try to use FrankenPHP. Not one even made it to QA aka it broke because during the dev testing.

Re:Show HN: A Better Log Service by hipadev23 on Sunday January 12, 2025 @02:55PM (#42676352)
Again, you don't have the slightest clue what you're talking about. There are numerous production-ready choices that myself and others have mentioned.
Re:Show HN: A Better Log Service by kgeist on Saturday January 11, 2025 @04:16PM (#42668992)
Sure, PHP can process logs of any volume, but it would require 5–10 times more servers to handle the same workload as something like Go. Not to say Go just works out of the box while for PHP you must set up all those additional daemons you listed and make sure they work -- more machinery to maintain, and usually they have quite a lot of footguns, too. Like, recently our website went down with just 60 RPS because of a bad interaction between PHP-FPM (and its max worker count settings) and Symfony's session file locks. For Go on a similar machine 60 RPS is nothing, but PHP can already barely process it, unless you're a guru of process manager settings.
Re:Show HN: A Better Log Service by Implicated on Saturday January 11, 2025 @04:23PM (#42669018)
This isn't a PHP problem, this is a configuration problem. You shouldn't be using the filesystem to handle your sessions in a production application.
Re:Show HN: A Better Log Service by kgeist on Saturday January 11, 2025 @04:44PM (#42669156)
Anything that unexpectedly blocks a process can bring down your entire PHP server because you will run out of worker processes. For example, imagine you experience a spike in requests while another server you're trying to call is timing out. You can't set the maximum worker count to a very high value because the operating system has an upper limit. Since the limit must remain low enough, you can quickly run out of your worker processes.

In contrast, Go can efficiently manage thousands of such blocked goroutines without issue. Sure, you can address this problem in PHP, but you need:

- understand PHP-FPM (or whatever you use) configs and their footguns

- understand NGINX configs and their footguns

- fiddle with PHP configs/optimizing your code to fit within PHP's maximum limits

- rent larger servers to have the same throughput

Re:Show HN: A Better Log Service by Implicated on Saturday January 11, 2025 @05:23PM (#42669423)
True. I stand corrected.

This is a footgun, regardless of if it's a block from file systems or remote requests or whatever.

My claim that it's a configuration problem is just a 'fix' and there are ultimately an unlimited list of ways this same thing can come up to bite you. Well, outside of aggressive timeouts - and even then, with enough volume of requests that's even not going to save you :D

Re:Show HN: A Better Log Service by Implicated on Saturday January 11, 2025 @04:29PM (#42669062)
> In Go, it's trivial to load tens of objects into memory to quickly process them, but PHP already starts falling apart before we hit 100k.

I'm not going to argue that PHP is _better_ than Go. Just starting off with that.

But if your background jobs are going OOM when processing large amounts of data it's likely that there's better ways to do what you're trying to do. It is true that it's easy to be lazy with memory/resources with PHP due to the assumption that it'll be used in a throwaway fashion (serve request -> die -> serve request -> die) - but it's also perfectly capable of long-running/daemonized processes that aren't memory issues rather trivially.

Re:Show HN: A Better Log Service by ryanianian on Saturday January 11, 2025 @11:38AM (#42666977)
PHP trivially scales up to multiple nodes behind an LB. You're really only limited by your backend storage connection count and throughput.

Go and friends may make for more efficient resource utilization, but it will be marginal in the grand scheme of things unless there are plans to do massively different things.

As it is this code is very simple. I haven't used PHP in 15 years and I was able to trace through this from front-end to back-end in less than 3 minutes.

To me it look like a really great level of complexity for the problem it solves.

Keep it up, OP.

Re:Show HN: A Better Log Service by that_guy_iain on Sunday January 12, 2025 @06:24AM (#42672805)
You can but that costs more money...

> Keep it up, OP.

Live in the real world. No one wants to have a fleet of servers for their logging infra when there are options to run it on a single server.

Re:Show HN: A Better Log Service by withinboredom on Saturday January 11, 2025 @10:20AM (#42666426)
PHP is arguably the best solution here. If a log ingestion process breaks everything, no other logs are harmed (a default shared-nothing architecture). Using something like Go, C#, etc, it might be "faster" but less resilient -- or more complex to handle the resiliency.

> But for the log processor that's going to need to handle a high throughput which PHP just isn't good at.

I'm sorry, but wut? PHP is probably one of the fastest languages out there if you can ignore frameworks. It's backed by some of the most tuned C code out there and should be just about as fast as C for most tasks. The only reason it is not is due to the function call overhead -- which is by-far the slowest aspect of PHP.

> you can have Go doing thousands of requests per second vs PHP doing hundreds of requests per second.

This is mostly due to nginx and friends ... There is frankenphp (a frontend for php running in caddy which is written in go) which can easily handle 80k+ requests per second.

Re:Show HN: A Better Log Service by that_guy_iain on Saturday January 11, 2025 @10:29AM (#42666488)
I'm going to have to also reply with, sorry but what?!

PHP is one of the fastest-interpreted languages. But compiled are going to be faster than interpreted pretty much everytime. It loses benchmarks against every language. That's not to mention it's slowed down by the fact it have to rebuild everything per request.

As a PHP developer for 15+ years, I can tell you what PHP is good at and what PHP is not good at. High throughput API endpoints such as log ingestion are not a good fit for PHP.

Your argument that if it breaks it's fine. Yea, who wants a log system that will only log some of your logs? No one. It's not mission critical but it's pretty important to keep working if you want to keep your system working. And in fact, some places it is a legal requirement.

Re:Show HN: A Better Log Service by hipadev23 on Saturday January 11, 2025 @11:52AM (#42667100)
How have you worked with PHP for 15 years and have absolutely no idea how it works or even baseline performance metrics.
Re:Show HN: A Better Log Service by Implicated on Saturday January 11, 2025 @04:11PM (#42668954)
He's not being truthful. Literally, there's no way that what he's saying is true. Either about various aspects of modern PHP or his experience with it.
Re:Show HN: A Better Log Service by withinboredom on Saturday January 11, 2025 @10:34AM (#42666519)
> It loses benchmarks against every language.

Every language loses benchmarks against every other language. That's not surprising. Since you didn't provide a specific benchmark, it's hard to say why it lost.

> High throughput API endpoints such as log ingestion are not a good fit for PHP.

I disagree; but ultimately, it depends on how you're doing it. You can beat or exceed compiled languages in some cases. PHP allows some low-level stuff directly implemented in C and also the high-level stuff you're used to in interpreted languages.

Re:Show HN: A Better Log Service by herbst on Saturday January 11, 2025 @11:01AM (#42666728)
On the other side some people (me) are happy to have an actual self hosting setup and not being forced to use a docker setup with unknown overhead.
Re:Show HN: A Better Log Service by xinu2020 on Saturday January 11, 2025 @11:48AM (#42667063)
Why not both? It's not much trouble to publish a Dockerfile while still documenting a normal installation.
Re:Show HN: A Better Log Service by herbst on Saturday January 11, 2025 @12:03PM (#42667187)
It's not, but more often than not it's just a dockerfile
Re:Show HN: A Better Log Service by williebeek on Saturday January 11, 2025 @10:58AM (#42666703)
Thanks for the tip, I will check if inserting rows with Go is any faster. For reference, inserting a log takes three steps, first the log data is stored in a Redis Stream (memory), a number of logs are taken from the stream and saved to disk and finally inserted in batches in ClickHouse. I've created it so you can take the ClickHouse server offline without losing any data (it will be inserted later).

For reference, moving about 4k logs from memory to disk takes less than 0.1 second. This is a real log from one of the webservers:

Start new cron loop: 2024-12-18 08:11:16.397...stored 3818 rows in /var/www/txtlog/txtlog/tmp/txtlog.rows.2024-12-18_081116397_ES2gnY3fVc (0.0652 seconds).

Storing this data in ClickHouse takes a bit more than 0.1 second:

Start new cron loop: 2024-12-18 08:11:17.124...parsing file /var/www/txtlog/txtlog/tmp/txtlog.rows.2024-12-18_081116397_ES2gnY3fVc

* Inserting 3818 row(s) on database server 1...0.137 seconds (approx. 3021.15 KB).

* Removed /var/www/txtlog/txtlog/tmp/txtlog.rows.2024-12-18_081116397_ES2gnY3fVc

As for Docker, I'm too much of a Docker noob but I appreciate the suggestion.

Re:Show HN: A Better Log Service by majkinetor on Saturday January 11, 2025 @10:18AM (#42666413)
It uses Clickhouse, though, which should be xtremelly fast for this.
Re:Show HN: A Better Log Service by that_guy_iain on Saturday January 11, 2025 @10:30AM (#42666489)
Yes. But PHP still needs to process it before it goes to Clickhouse. PHP is the bottleneck.
Re:Show HN: A Better Log Service by axelthegerman on Saturday January 11, 2025 @11:07AM (#42666770)
If that "bottleneck" is thousands of requests per second then it doesn't really matter for smaller deployments does it? (Which seems to be the target audience and not FAANG)

I'm not a big fan when folks call out languages as bottlenecks when they have no proof on the actual overhead and how much faster it would be in another language.

Re:Show HN: A Better Log Service by that_guy_iain on Saturday January 11, 2025 @11:36AM (#42666969)
To tweak a PHP deployment to handle hundreds of requests per second which is very very realistic for a basic logging for a mid-sized application you're looking at having a very beefy server setup.

Most PHP deployments barely reach a hundred per server.

And this is an open source project is should be designed to handle basic production workloads which it could but it'll cost you a bunch more than if you used the correct languages.

> I'm not a big fan when folks call out languages as bottlenecks when they have no proof on the actual overhead and how much faster it would be in another language.

Honestly, I thought it was so obvious that an interpreted language is not good for high throughput endpoints that it didn't need to be proven. I also thought it was obvious that a logging system is going to handle lots and lots of data.

It could be easily proven by doing a bunch of work but obviously there is no point in me proving it.

Re:Show HN: A Better Log Service by withinboredom on Saturday January 11, 2025 @01:08PM (#42667717)
I rebuilt durable-functions in php. Durable Functions is a C# actor model runtime. My PHP implementation meets or exceeds the same benchmarks as the C# version.

> It could be easily proven by doing a bunch of work but obviously there is no point in me proving it.

Because you cannot prove it... :) I wrote this post a few years ago, that actually spurned some improvements in C# ... so here you go: https://withinboredom.info/2022/03/16/yes-php-is-faster-than...

Re:Show HN: A Better Log Service by that_guy_iain on Saturday January 11, 2025 @01:36PM (#42667943)
No, it's because I've got productive things to do that do benchmarks that have already been done repeatedly. The only way to get PHP to the same speed as compiled languages for web requests is to use experimental tooling.

I notice your benchmarks are over 10 runs?! That's not a good sample size. And even more importantly, it's not in the same context.

Sure once you compile PHP and have it running it'll run fast. But PHP has a very specific usage which is web applications. It's been well-known for years that PHP's performance issues are related to the fact it's an interpreted language that has to be interpreted everytime but if you compile and run repeatedly it can perform extremely well. Which is why every performance related PHP nerd is working on experimental tools to do that.

Re:Show HN: A Better Log Service by withinboredom on Saturday January 11, 2025 @03:07PM (#42668567)
> That's not a good sample size.

Like I said in the blog post, if I tell you the sky is blue and you don't believe me; run them yourself. FWIW, C# is faster now for that particular use case. Also, like I mentioned in a previous blog post ... which one would you rather maintain:

- https://github.com/TheAlgorithms/C-Sharp/blob/master/Algorit... -- merge sort in C# 130 lines

- https://www.w3resource.com/php-exercises/searching-and-sorti... -- merge sort in PHP 60 lines

PHP is often far more concise than C#, and many other languages. I code more in Go than C# or PHP these days, but even Go has its limitations where it would be easier to express in PHP than Go. There are even certain classes of algorithms that are butt-ugly in Go but quite pretty in PHP.

PHP is still my favorite language, even though I hardly get to use it these days.

> PHP has a very specific usage which is web applications.

Originally, yes. But it outgrew that about 10 years or so ago. It's much more general purpose now.[1][2]

[1]: https://nativephp.com/ -- desktop applications in php

[2]: https://static-php.dev/ -- build self-contained, statically compiled clis written in php

Re:Show HN: A Better Log Service by phillipcarter on Saturday January 11, 2025 @04:13PM (#42668974)
The C# to PHP comparison is not fair, as the link you gave for the C# code uses abstractions to support "arrays" that could also be backed by file storage. An equivalent translation of the PHP code is about 60 lines as well, before applying any code golfing (and including comments and whitespace).
Re:Show HN: A Better Log Service by neonsunset on Saturday January 11, 2025 @04:12PM (#42668963)
You do realize that you are comparing two different implementations with different type systems that use different abstractions? Clearly you can't be serious. So, unless you are being intentionally misleading, this raises serious questions about the quality of "PHP solution" that is being worked on.

In any case, please stop making the world a worse place by writing more PHP, thank you.

Re:Show HN: A Better Log Service by withinboredom on Saturday January 11, 2025 @05:15PM (#42669375)
I'm being serious in using it as an example of maintainability/expressiveness. The difference is deliberate, not accidental. I've written 15 PHP lines that would be hundreds of lines in C#, and I've written 15 lines of Go that would be hundreds of lines of PHP. Every language has its own strengths and weaknesses and levels of complexity. PHP fits into a sweet spot (IMHO) of low-levelness and high-levelness, but it is often not seriously considered due to its reputation in the 00's.
[dead]
Re:Show HN: A Better Log Service by withinboredom on Saturday January 11, 2025 @03:20PM (#42668636)
> Furthermore, the garbage collector is still designed for web requests.

Don't tell Swift about this...

Re:Show HN: A Better Log Service by mrngm on Saturday January 11, 2025 @02:48PM (#42668446)
I'm sure you've heard of PHP's opcache by now. That's not experimental and actually caches the interpreted code in memory for faster subsequent execution.
Re:Show HN: A Better Log Service by withinboredom on Saturday January 11, 2025 @03:02PM (#42668530)
Yes, and in 8.4, uses an actual IR for machine code generation and is pretty cool!
Re:Show HN: A Better Log Service by that_guy_iain on Saturday January 11, 2025 @03:13PM (#42668601)
Yes, it makes it faster but does not deal with the core performance issues which is why Roadrunner, Frankenphp, etc exist.
Re:Show HN: A Better Log Service by Implicated on Saturday January 11, 2025 @04:09PM (#42668942)
I see, you're just trolling at this point.
Re:Show HN: A Better Log Service by mrngm on Saturday January 11, 2025 @03:38PM (#42668749)
Well, looking at our bespoke logging system in PHP handling some 15-20+ million log entry's per day on a virtualized dual-core system... it's mostly disk I/O on the underlying MySQL database (currently duplicating to Clickhouse where we'll eventually store everything). And that is central application logging for about 100 servers (think syslog), some 400 "microservices" (parts of a larger application), and a handful of backend systems.

We're running out of disk space earlier than that PHP is a bottleneck here.

Re:Show HN: A Better Log Service by Implicated on Saturday January 11, 2025 @04:00PM (#42668894)
> To tweak a PHP deployment to handle hundreds of requests per second which is very very realistic for a basic logging for a mid-sized application you're looking at having a very beefy server setup.

There's just no way that you're at all familiar with PHP of the last 10 years to think this is true.

> It could be easily proven by doing a bunch of work but obviously there is no point in me proving it.

Prove it. Please, show me the context and environment you think PHP would struggle to serve "hundreds of requests per second". I'd venture a bet that a plain Laravel installation on the cheapest digital ocean droplet would top this and Laravel is "slow" in relation to vanilla PHP.

Re:Show HN: A Better Log Service by robocat on Saturday January 11, 2025 @04:04PM (#42668912)
Are you sure PHP is the bottleneck?

The author writes that Clickhouse takes 0.1s for an example request: https://news.ycombinator.com/item?id=42666703

PHP would need to be adding 0.1s CPU time for processing the request for the PHP code to become the bottleneck. That seems unlikely.

Re:Show HN: A Better Log Service by thunky on Saturday January 11, 2025 @09:43PM (#42670835)
That 0.1s is to write 4k rows to clickhouse, not per (log write) request.
Re:Show HN: A Better Log Service by majkinetor on Saturday January 11, 2025 @10:16AM (#42666403)
No benefit using go over C#, IMO, and I am also baffled by the switch
Re:Show HN: A Better Log Service by that_guy_iain on Saturday January 11, 2025 @10:31AM (#42666494)
I just used go as an example, any compiled language would be better.
Re:Show HN: A Better Log Service by withinboredom on Saturday January 11, 2025 @10:45AM (#42666590)
I highly suspect it wouldn't be better in brainfuck...