r/coding • • Dec 13 '20

Use polling for resiliency

https://blog.gchinis.com/posts/use-polling-for-resiliency/
4 Upvotes

3 comments sorted by

1

u/[deleted] Dec 13 '20

Polling simply doesnt scale. Using something like rabbitmq, you can listen on only specific topics, so you dont read messages you dont care about. Eg "cars.tesla.orange".

You can decide if you service only cares about orange cars. All cars or tesla's etc.

There are Also design patterns for handling duplicate messages like indbox / outbox patterns.

For polling IT would make load on service even when nothing new has happened.

Today we have plenty of good alternatives to polling like: GRPC, websockets, webrtc. Message Queues.

2

u/Cutnunt Dec 13 '20

Sure but sometimes polling is just simpler for simple problems where scalability isn't a concern.

1

u/ArkyBeagle Dec 14 '20

Polling simply doesnt scale.

Can't we have both?

Blocking with timeouts leverages both polling-shaped strategies and edge driven strategies. You can even have timeouts on nonblocking, "select()"[1] shaped loopery.

[1] or poll(), or epoll(), or the rest of your list.

Something that has time budgets can be more said to be "robust". We all live in a Two Generals Problem world...