HTTP/2 Multiplexing and Go requests

I’m doing some research on the features of HTTP/2 and am seeing how Go handles them. Particularly, I like the new feature of Multiplexing in HTTP/2 where you can send requests in parallel and get responses back in parallel. As opposed to HTTP/1.x where, for the most part, you have to send a request and wait for the response before continuing on.

I don’t see any straightforward documentation/discussion about this topic however. For context, I’m looking into writing a library/application that handles sending notifications for Apple Push Notification Service (APNs), with the goal of getting the most speed possible for the use case of sending a single notification to a large number of devices. This is akin to news bulletins from apps such as NY Times, AP, etc.

Would this be as simple as making multiple requests in parallel via several goroutines? For example, in the case of sending 100,000 notifications, have 8 goroutines running that continually put the requests on the wire and get back responses by themselves, all on a single HTTP/2 TCP connection (read: single http.Client)? The doc mentions that http.Client.Do() is safe for concurrent use, but I’m not sure if it takes advantage of HTTP/2 Multiplexing or not.

And if I’m misunderstanding something, either about HTTP/2 or the Go http.Client, please let me know.

Sth like https://github.com/mercari/gaurun ?

Your plan is viable iff you connect only to a handful of http2 servers.

Thank you for the information! The underlying framework of that link, https://github.com/RobotsAndPencils/buford/ seems to confirm that as well.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.