News for hackers. Stuff that matters.
Re:How We Manage a Million Push Notifications an Hour by londons_explore on Friday August 30, 2019 @06:21AM (#20837259)
1 Million per hour is only 300 per second. On a 1.5 Ghz 4 core raspberry pi, that gives you 21 million clock cycles to deal with each message.

The architecture seems rather overengineered considering a single raspberry pi could do the job, even after 100x scaling!

Re:How We Manage a Million Push Notifications an Hour by lmilcin on Friday August 30, 2019 @07:39AM (#20837603)
I wrote an algorithmic trading framework to work on Warsaw Stock Exchange.

WSE back then had a limit of 10k messages per second (as in one message every 1/10000th of a second). Messages came by two separate network operators so that was 20k messages to be deduplicated to 10k operations. Incomming messages came in compressed so they required uncompressing.

Responding to the message required complex processing and then may have resulted in an order to market which, again, had to be constructed and validated.

All this worked on a single server (regular two-socket Xeon-based server).

There was 10us (microseconds..) time budget to send response to the market and it had to work every time even under maximum possible load (10k messages per second).

Routing and forwarding 300 messages per second doesn't seem like something to brag about...

Re:How We Manage a Million Push Notifications an Hour by cristaloleg on Saturday September 07, 2019 @10:43AM (#20904034)
Hi from Warsaw, care to tell something more about architecture, used technologies, numbers? Thanks in advance.
Re:How We Manage a Million Push Notifications an Hour by tempguy9999 on Friday August 30, 2019 @08:09AM (#20837749)
Yep, I hit the calculator first thing too, but I think your criticism is not quite fair, after all the data has to be pulled off disk and acknowledgements written back.

That said, it really doesn't sound too difficult with straightforward architecting (says the armchair critic).

Re:How We Manage a Million Push Notifications an Hour by danpalmer on Friday August 30, 2019 @08:08AM (#20837747)
I think this is a disingenuous or naive view, while you may not have been serious, I think it's worth unpacking why it's naive as I think a lot of engineers have similar opinions.

To start, there's nothing here about what machine this architecture runs on, it could be running on a Raspberry Pi for all we know.

Then, this ignores the cost of database lookups for the keys. That data is probably small enough to be on the one machine, but then you have to have service support for (reliably, in real time) syncing that data to the service. A separate database is therefore probably the right solution here, which means you're doing networking in each message send, which makes it unlikely that a Pi could do this.

Next up you've got the issues of reliability. The message queue separation gives you better reliability in the face of issues such as upstream APIs going down or erroring, or issues for a specific user. All the business logic around handling this, the message queue handling persistence and ACID semantics (or parts of it), this all takes additional resources, not to mention potentially a fair bit of disk space (for a Pi) to queue up undelivered messages should an upstream API slow down or stop accepting new messages.

Then you have hardware failure, at this scale you don't want a single machine failure to wipe out your primary communication method with millions of customers. You'd therefore want to have a distributed system, even if that's only for reliability rather than performance.

Lastly, 21 million clock cycles might sound like a lot, and might go a long way with C/C++/Rust, but as you move up to more dynamic languages that will reduce significantly. It happens that they are using Go here, and that's likely to get pretty good performance out of the hardware, but writing this service in Python/Ruby would be a very valid choice for developer productivity, or based on existing skills they have in the team. That might be 1/10th the performance, but since you need a distributed system for reliability here anyway, adding a few more machines to the pool might be a better choice than introducing a lower level language that takes longer to develop and exposes you to memory safety or threading issues.

There may well be other factors I haven't considered here, but I think for the use case of delivering that scale of messages, the reliability options you get with a system like this are well worth the additional hardware requirements and architecture overhead.

Edit: lmilcin makes a good point about trading systems, but there are several differences – that system still has a single point of failure, it was probably written in a low level language with input from experts on performance, and it was running on a much faster machine. The single point of failure of a server-grade machine like that is probably an acceptable risk if you own the hardware, but in a cloud environment (which brings other benefits) hardware is less reliable so probably not an acceptable risk there. I don't think it's an apples-to-apples comparison, although it is interesting.

Re:How We Manage a Million Push Notifications an Hour by tempguy9999 on Friday August 30, 2019 @08:27AM (#20837854)
I partly agree with you but you're probably over-engineering it. They talk about "GoLife booking notifications" and "promotional notifications". Neither of these require (edit: I mean sound like they require) once-only semantics. If you're OK with very rarely failing over then restarting from scratch on the failover machine is ok. Even if not, pushing batched IDs ("I've done IDs xyz..) over a network to the failover machine would remove most of that. I don't think it needs ACID semantics.

> Then you have hardware failure, at this scale

It's really, really, not scale!

> Lastly, 21 million clock cycles might sound like a lot, and might go a long way with C/C++/Rust, but as you move up to more dynamic languages that will reduce significantly

Then you're prob using the wrong lang.

I don't really accept that level of engineering is necessary all round, unless the business case requires it, and then I'd speak to whoever put those business requirements together and ask hard questions.

Re:How We Manage a Million Push Notifications an Hour by danpalmer on Friday August 30, 2019 @09:07AM (#20838171)
> It's really, really, not scale!

Talking to 1 million different people an hour is _business_ scale. Regardless of the tech required to do that, it not working would likely be a significant business impact.

> Then you're prob using the wrong lang.

There's so much more here than performance. There's developer productivity, there's tooling availability, all sorts. They happen to be using Go which is probably the best trade-offs for this particular system, but if you were doing complex machine learning you'd probably want to use Python due to all the excellent tooling available, and that means having a "slow" language for parts that aren't optimised for you.

If the difference is 1 engineer, ~1k lines of code, 3 machines, vs 3 engineers, ~10k lines of code and 1 machine, the former is likely to be the right trade off for most companies. It's cheaper to build, and since number of bugs typically correlates to lines of code, it will likely be much more reliable.

As for the ACID semantics, you're right you wouldn't need them all here, redelivery is probably fine within some bounds, and the upstream APIs might even have idempotency tokens to prevent this, but the downtime of losing a machine for a few hours, the time to regenerate all those messages that were lost on the downed machine, etc, could equate to quite a bit of downtime and poor UX for users.

You're not wrong from a performance perspective, but taking into account reliability, business impact, user experience, and developer productivity/costs, I think the solution in the blog post is a better set of trade-offs than you're suggesting.

Re:How We Manage a Million Push Notifications an Hour by thewarrior on Friday August 30, 2019 @07:51AM (#20837651)
And what happens if the raspberry pi goes down for an hour ?
Re:How We Manage a Million Push Notifications an Hour by londons_explore on Friday August 30, 2019 @07:56AM (#20837677)
You spend $35 on a spare.
Re:How We Manage a Million Push Notifications an Hour by thewarrior on Friday August 30, 2019 @08:25AM (#20837841)
And what if you don’t want to lose the notifications in the time it went down ?
Re:How We Manage a Million Push Notifications an Hour by nurettin on Friday August 30, 2019 @08:12AM (#20837764)
Odroids have better price to performance in my opinion.
Re:How We Manage a Million Push Notifications an Hour by Merg on Friday August 30, 2019 @09:16AM (#20838236)
You buy ten more before hand and have all of them running side by side, to retake workload on any outage.

Replace raspberry pi with any local server configuration.

Re:How We Manage a Million Push Notifications an Hour by thewarrior on Friday August 30, 2019 @10:22AM (#20838862)
Well now you have an architecture.
Re:How We Manage a Million Push Notifications an Hour by jiveturkey on Friday August 30, 2019 @12:04PM (#20839858)
My thoughts exactly.

One million per hour? I forgot how to count that low.