Docs about not using schedulers and bacground jobs

its nakama doc:

To avoid “dead work” - done when the user is not present - and the unnecessary server load, background jobs should be avoided in favor of an event driven route. In this approach, the client makes an RPC call when the user returns, and in that called function any updates required by your game logic and use case are performed.

Where a scheduled background job would needlessly perform these updates across the entire user base, regardless of a user’s inactivity, this approach ensures that work is only performed for users still active in the game.

Use of background jobs can cause further problems as any job would be limited to one Nakama instance, requiring either duplication across all instances or a non-homogenous workload across instances.


assume I need weekly leaderboards or time based events. how should I handle such scenarios.

and in general in nakama go plugin I only should write code for requests?

Hi @virtouso :wave:

assume I need weekly leaderboards or time based events. how should I handle such scenarios.

With leaderboards (daily/weekly/monthly/etc) we provide all the handling which allows you to handle reward distribution and notifications to players at the end of an active phase. Have a look at this documentation example which covers how you can use initializer.RegisterLeaderboardReset to create your own handler function which will be called on active phase end:

Tiered Leagues - Heroic Labs Documentation

With time-based events it really depends on the specific type of game design for the event. In our game framework Hiro we have two types:

  • Solo Timed Live Events, we implement these as a simple collection of SubAchievements in an Achievement which has a reset schedule configured for it. The reward collection and completion as well as how the active phase end is handled is all done without any background jobs.
  • Event Leaderboards, we implement these on top of Nakama Leaderboards but also do not register a reset handler. A player is allowed to collect rewards before they join the next active phase of the event so its all handled on demand per active player.

Sometimes it can be required to use the reset handler on a leaderboard for the type of Event Leaderboard reward distribution but with gameplay systems like Daily Bonus Rewards, Win Streaks, and many others its not needed to use background jobs of any kind.

and in general in nakama go plugin I only should write code for requests?

You can write in whichever language supported by the server framework you’re most comfortable and productive with. My personal preference is Go but I have good experience with Go already as an engineer who works on Nakama, Hiro, and Satori. :smile:

Hope this helps.