Please consider the following set of facts:
* While you did not explain that, "502 errors" appear to mean
some HTTP requests complete with the server answering with responses
containing the 502 HTTP status code.
Sadly, you did not tell us which HTTP requests actually fail this way.
* Aerospike does not use HTTP as its client protocol; it implements some
custom protocol over TCP sockets, so that 502
* HTTP status code 502 is defined to mean "Gateway Timeout".
Based on these facts I could do a guess: you have a setup like this:
[your clients] → [http proxy] → [your Go program] → [aerospike]
Depending on how your Go server is deployed, you can be easily unaware that an
HTTP proxy - such as nginx - is sitting between your server and your clients.
When the load from the client increases, the request handling code starts to
spend progressively more time in the calls which send data to Aerospike,
and eventually some of them spend so much time doing that they surpass a
maximum time span configured in that HTTP proxy which any request is allowed
to spend. Once a request trips that threshold, the proxy rips it and returns a
response to the client, telling it the service it mediates access to is not
keeping up.