Nakama 2.0 - Scale for millions of concurrent players
Today we announce the release of Nakama 2.0! This evolution of Nakama brings unprecedented support for new game engines, libraries, development tools, and languages in order to give developers the utmost in flexibility when it comes to choosing the right tools to build the best games possible.
The primary focus on 2.0 has been increased flexibility, several large new features, ease of use in development with a new REST API, many quality of life improvements from our learnings in working with many studios across the world, and even greater scalability for games that require hundreds of thousands of simultaneous connections. As the future of gaming evolves into requiring more demanding, always-online gameplay, Nakama is architected to fill that gap.
It is important to note that with this update there are some major changes and if you choose to upgrade from prior versions you will need to integrate our brand new client libraries to support 2.0.
However, you do not need to upgrade. We have studios currently using various versions of Nakama 1.x for their games as those versions power all of the features they require. Updating your server is entirely dependent on your needs. If you have any questions please reach out to us to discuss further.
Settle in and grab a comfortable seat — there’s a lot to share with you about 2.0 coming up!
For those out of the loop: Nakama is an open-source, distributed server built to scale for games and apps up to tens of millions of monthly active users. It is a clustered server designed to power all types of games — from PvP mobile games, match-3 puzzlers, to FPS’, MMO’s, various types of apps, and more.
In technical terms Nakama is a GRPC, GRPC-Gateway, and Go-powered App server designed to be the foundation and simplification of backend services for games and apps. With a dedicated team of engineers working on Nakama daily to add features, new client libraries, battletest it at scale, and improve the experience for developers — why reinvent the wheel with each new project and studio? Nakama provides a foundation for ease of use, scalability, and ownership over your core tech stack.
By far one of the most requested features since our introduction of the Advanced Matchmaker into Nakama has been for an authoritative server component. With 2.0, we’re pleased to announce this has been included as a first-class server engine. Designed and implemented over several weeks, and with over 3,000 lines of code, the pull request for authoritative was merged into the codebase. This gives developers the power to manage game state server-side, reduce cheating, and easily build authoritative games such as Poker or more involved Clash Royale style games with various rule sets.
The server authoritative engine works by creating a Lua Virtual Machine, one per goroutine, each with its own lifecycle dedicated to a match required by a game. These VM’s define a set of functions that are invoked on various events within the game server. The server runs at a fixed tick rate in the background, which is configurable in your code, and determines when to resume/pause match state based on your game logic functions. On each tick, the server passes the received inputs from the client, with order guarantees, to the match to progress.
You load your custom Lua modules by placing them in a specific directory which are then loaded and evaluated by the server at startup and executed within your game. This system can also create custom functions which are called over RPC to implement any game logic you want. Logic like referral rewards, game win conditions, input velocity checks, etc. are all possible within the engine.
This is such a powerful and comprehensive feature we’ll dedicate a separate follow up post with more details on how it all works. We also have a tutorial for Tic Tac Toe which will demonstrate most logic and the core server-side game loop in execution.
Within 2.0 we’ve split out the socket protocol to reduce the requirements around when sockets are used with the realtime API. This changes the surface area that uses sockets and accelerates development whilst using Nakama. It enables much easier integration with existing game engines and development tools, meaning more client libraries for a variety of other engines are now easily accessible. We’d love to hear from you which game engines you would like support for — some on our most-wanted list include Cocos2d-x, Godot engine, and Defold.
Extended Presence Events
The existing presence system in Nakama has been incredibly effective as the bedrock for communication between players across groups, chat, and multiplayer. In order to enable simple presence events be registrable for players we decoupled it from the chat system.
It’s now easy to show when any other player comes online regardless of your current relationships or activity with them. Whether these are existing friends, group/clan members, other clans, or former opponents who you’ve matched with before and want a re-match. Games can become more social, more realtime, and more engaging with this larger presence event system. It is, of course, entirely up to developers to determine to what extent they would like to share these presences across users based on the gameplay requirements.
The General Data Protection Regulation (GDPR) which comes into effect May 25th, 2018 will have far-reaching consequences for games and app developers. With our technology deployed by studios all over the world, and the likelihood of Privacy Shield in the United States and other regulatory bodies adopting similar rules from GDPR, we wanted to ensure Nakama was prepared regardless of which countries your players reside in.
Two of the most important tenets of GDPR as related to the server are:
- The right to be forgotten: all user data erased, including on backups
- The right of access: a copy of all data the company has on a user
Our Heroic Cloud service is fully GDPR compliant for when you won’t want to run servers, manage scale out, backups, load balancing, SSL termination, and more.
Subscribing to Status Updates
As part of expanding the capabilities of the server, players can now subscribe to others players’ status updates. It can be as simple as an indicator as to whether a player is currently online or not (think Steam Friends status’, for example), to complex usage with JSON inputs so that a player can tap their friends name and join a multiplayer match.
This makes it even easier for players to join a Direct Message chat room, update their clanmates on their current status, and encourage even more social behaviour within games. Players can also set their own status to indicate things such as the fact they’re looking to play a game, a clan to join, etc.
HTTP Support / Swagger
We have introduced a Swagger specification for the server API. Swagger is a very popular open-source API framework.
The unprecedented demand for Instant Games support has influenced our goal of ease of use and code maintenance across all of our ecosystem code around the core game server. We’ll have a follow up with a detailed post on our tips and best practices for getting the most out of Nakama for that new blue ocean of opportunity.
With our embedded Lua code runtime useful to run authoritative commands, we’ve extended it to provide functions directly for Virtual Wallets. This allows you to easily create a unique wallet for each user and verify that they have the correct amounts of gold, wood, diamonds, or whatever your in-game economy uses.
This reduces the ability of users to easily cheat your in-game economy as well as simplifies the process to reward users directly either from their actions in-game or to allow support staff to fix a problem or simply thank a user for their actions. A good example of using the wallet authoritatively would be for players to have limited ‘lives’ during certain events or tournaments and the ability to spend them to get back into the game as a second or third chance.
With the release of CockroachDB 2.0, which added JSONB support, we’ve quickly moved to update our builtin storage engine and schema for Nakama to support it as well. Using a JSONB column gives you the flexibility to store any metadata you require in your games that remains queryable by the database.
By choosing JSONB instead of standard JSON, this offers a substantial improvement in the reduction of time it takes for a query to find the correct document and pass it to the client. This feature is particularly useful in conjunction with the virtual wallet or storage engine systems within Nakama.
In Your Hands
As always, Nakama is in your hands. As an open-source server, we welcome and encourage all community feedback and contributions. Together, we can democratically and transparently build the foundation of all present, and future games and apps across all platforms. No more black box services, no more wondering if what you’ve built will operate at scale — with Nakama you can build on a production-ready foundation in order to create massively social, and massively realtime games.
Nakama 1.0 set a minimum standard for features and scalability required to power modern, live games. 2.0 is the next evolution to make backend development and integration as effortless as possible whilst still maintaining the flexibility studios require to build any type of gameplay they desire and to build for the largest of games imaginable.
Thank you for joining us on our journey to enable developers, of all experiences and backgrounds, to build bigger and more social games. We hope you will drop in on our community forum to speak with fellow developers, and star the project on GitHub.