uniqush / uniqush-push

Uniqush is a free and open source software system which provides a unified push service for server side notification to apps on mobile devices.
http://uniqush.org
Apache License 2.0
1.54k stars 201 forks source link

Use a single shared connection pool for GCM pushes, set timeouts on gcm requests #127

Closed TysonAndre closed 8 years ago

TysonAndre commented 8 years ago

instead of creating a lingering connection for every push.

Doing this greatly reduces the number of open connections for GCM, and the number of connections. It also decreases CPU usage noticeably when there are active GCM PSPs, and should decrease latency.

Previously, uniqush-push was creating http.Clients every time a push request was made. Each http.Client has its own instance of a connection pool.

https://golang.org/pkg/net/http/#pkg-overview

Clients and Transports are safe for concurrent use by multiple goroutines and for efficiency should only be created once and re-used.

Add a timeout of 10 seconds for pushes to GCM servers. It's undesirable to wait forever for a request to finish if there are network errors.

mishan commented 8 years ago

:+1: :sheep: :it: