在Go服务中,以每个用户为基础使用Redis pubsub的内存高效方法是什么?

huangapple go评论77阅读模式
英文:

Memory efficient way to use Redis pubsub on per user basis in go service?

问题

我们使用GraphQL订阅将数据推送到客户端。在使用Go语言编写的GraphQL服务器上,我们为每个用户订阅连接到一个pubsub频道(每个用户的频道是唯一的)。在测试过程中,我们注意到随着每个新用户订阅的增加,Go服务的内存消耗开始迅速增长。

对于如何减少这种实现的内存占用,您有什么建议吗?

英文:

We use GraphQL subscriptions that push data to the client. On the GraphQl server, written in golang, we connect to a pubsub channel for each user subscription (channel is unique for each user). While testing we noticed that the go service memory consumption started to grow really fast with every new user subscription.

Any recommendations on how we make this implementation less memory intensive?

答案1

得分: 1

你现在最好的做法是对你的程序进行分析,找出问题的原因。你可以参考这篇文章了解如何对程序进行分析。https://medium.com/@openmohan/profiling-in-golang-3e51c68eb6a8

请按照这篇文章获取更多关于如何对程序进行分析的信息。

英文:

The best thing you can do now is to profile your program to find out the reason behind the problem
https://medium.com/@openmohan/profiling-in-golang-3e51c68eb6a8

Follow the article for more information on how to profile a programs

huangapple
  • 本文由 发表于 2023年4月1日 01:06:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/75901049.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定