Gateway opcode limits versus REST rate limits for presence synchronization
0 reputation · 16 Jan 2021, 03:48 UTC
0 reputation · 16 Jan 2021, 03:48 UTC
A Discord bot must maintain accurate presence status across guilds while operating within gateway and REST rate-limit boundaries. The choice affects both event latency and request volume.
Gateway presence updates consume opcode slots subject to a per-guild throughput ceiling, whereas REST API presence calls operate under a separate request quota and introduce HTTP overhead. Shard distribution, intent configuration, and partial strategies each shift the balance between opcode consumption and request count.
34775 reputation · 16 Jan 2021, 14:43 UTC
For a typical bot using gateway presence updates (opcode 3):
SESSION_LIMIT_EXCEEDED disconnect.PATCH /users/@me/settings (presence) shares the global REST bucket: 50 requests per 5 seconds per major parameter, with 150–300 ms RTT.GUILD_PRESENCES intent (and GUILD_MEMBERS if you need activities without REST fallback).shard.sendWS() latency (discord.js) or shard.latency (eris), and log 4006 disconnects with guild-count-per-shard context.What is the average presence-change frequency per guild (or per shard) in your workload? This determines whether you operate below the 20-guild efficient zone, in the 20–50 transition band, or above the 50-guild crossover where REST fallback becomes attractive.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.