architecture

jaihindhreddy 2021-02-15T18:05:48.108500Z

Need help in implementing a webhook client: I have a Google PubSub topic of data-representations of HTTP requests, and I need to execute all of those requests. All of these requests are to the same domain. Assuming all of them are idempotent, how can I implement a subscriber process to achieve maximum throughput? I'm thinking of using an async HTTP client, and implementing something akin to TCP flow-control, but at the HTTP layer, so that the process "finds" the optimum throughput, using 5xxs and 429s as backpressure. Am I on the right track?

jaihindhreddy 2021-02-15T18:06:35.109200Z

^ As far as throughput is concerned, it could be upto a thousand HTTP requests per second (peak not sustained). Is this even achievable with one process?

emccue 2021-02-15T20:55:51.112200Z

Say each http request takes 100ms

emccue 2021-02-15T20:55:58.112500Z

you have 1 second to do 1000 of them

emccue 2021-02-15T20:56:08.112700Z

each thread can do 10 in that time

emccue 2021-02-15T20:56:13.112900Z

so you need 100 threads

emccue 2021-02-15T20:56:38.113500Z

OR you need to use a reactive library that yields on IO

emccue 2021-02-15T20:57:32.113900Z

thats in JVM land

emccue 2021-02-15T20:58:02.114500Z

if you used something like rust or nodejs for this bit, you can use their async/await stuff to reach your IO throughput easy

vemv 2021-02-15T21:02:23.116700Z

Not sure if I agree with the dichotomy between threads and reactive libraries. One can use java.nio http from vanilla threads right?

2021-02-15T21:04:28.118600Z

the number you need to do per time period and the length of time each takes will tell you how many you need to do concurrently, the number you need to do concurrently will tell you if a thread per request will be fine or not

2021-02-15T21:12:36.120700Z

100 threads is basically nothing

2021-02-15T21:16:40.122Z

the back pressure tuning will be, at least a little easier to implement with a thread per request, because you will just be tuning up and down the number of threads the threadpool has to make requests

2021-02-15T21:19:00.123900Z

for some none blocking http client (java even has one built in these days https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html) you'll need to do your own accounting for how many are in progress

2👍
gklijs 2021-02-15T21:54:15.128300Z

I worked with a couple of reactive frameworks on the JVM. But they seem much more hassle in maintaining then a few additional vm's would have been..

2👍