azure-sdk-for-go: [azservicebus] Memory leak when receiving messages
Bug Report
- Package in question
azure-sdk-for-go/sdk/messaging/azservicebus - SDK version
v1.5.0 - go version
1.21
- What happened?
We are trying to move away from the deprecated azure sdk for service bus https://github.com/Azure/azure-service-bus-go and use e the new in one of our services. This service is heavily reading on messages from a Service Bus Queue. We are noticing an increasing usage of memory.
Also from profiling data we can see that the Heap size increase is happening at go-ampq code
- What did you expect or want to happen?
I would expect the new SDK to have a different memory footprint (either higher or lower memory consumption) but after some time i was expecting the memory usage of the service to be stable as before and not increasing time over time.
- How can we reproduce it?
Not sure how easy it is, as we need to leave the service running for a couple of days to start seeing the increase in memory usage.
- Anything we should know about your environment.
Data shared above are from staging environment. I am expecting bigger usage on a prod environment with much higher traffic.
Our setup is we are using a number of worker goroutines each one receiving messages from a client.Receiver in parallel.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 28 (18 by maintainers)
Commits related to this issue
- [azservicebus] Fixing memory leak with go-amqp update. (#22253) go-amqp got a fix recently that replaces its internal tracking map with a counter, which eliminates a rare memory leak we'd see if you ... — committed to Azure/azure-sdk-for-go by richardpark-msft 3 years ago
- [skip secret scan] Merge with Azure/azure-sdk-for-go (#13) * Sync eng/common directory with azure-sdk-tools for PR 7385 (#22112) * Update organization of the eng/common/testproxy folder * Add mer... — committed to confluentinc/azure-sdk-for-go by nichjang 3 years ago
Richard and I spoke about this offline. The reason the
go-amqp@v1.0.3change didn’t fix this is because cross-receiver settlement at theazservicebuslevel bypasses thego-amqplayer.I’ve released
go-amqp@v1.0.4which replaces the unsettled messages map with a count which should fix this.@gkampitakis FYI we’ll be releasing an updated
go-amqp(should be today) that fixes the cross-receiver message settlement memory leak.@richardpark-msft
We are using a pool of receivers to ReceiveMessages concurrently from multiple goroutines, process them and then complete them. So from the pool you pick a random (available) receiver to ReceiveMessages and then have a single receiver that settles the messages.
Thanks both for your time spent on this 🙇. I couldn’t have figure it out. Will try to work around this and use the same receiver for both operations.