Colyseus - Multiplayer Game Client & Server

Yes, in the colyseus-defold repo #

1 Like



Hello, I’m trying to make a game with syncronous multiplayer with Colyseus and Defold and I have perfomance issues.
At first I was using state sync and messages from server to sync clients. State sync was working on 30 FPS and whole game has around 10 FPS on HTML5, Android, Windows and Mac versions because of

local new_state = msgpack.unpack( utils.byte_array_to_string(self._previousState) )

in room.lua Room:patch.

Then I turned off room patch by copying library to my project and commenting room.lua:87


and sending state info by message from server to clients every frame at 30 FPS. One message contains array of 6-10 elements like this

2 = {
    segmentRadius = 32,
    skin = cat,
    id = 2,
    segments = {
      1 = {
        y = -316,
        x = -85,
      2 = {
        y = -308,
        x = -93,
      3 = {
        y = -303,
        x = -82,
      4 = {
        y = -295,
        x = -90,
      5 = {
        y = -290,
        x = -79,
      6 = {
        y = -285,
        x = -68,
      7 = {
        y = -277,
        x = -76,
      8 = {
        y = -272,
        x = -65,
      9 = {
        y = -264,
        x = -73,
      10 = {
        y = -259,
        x = -62,
    name = Jessica Jones,
    isolationTimer = 23,

On Windows, Mac and Android it works perfect, but on HTML5 game works at stable 30 FPS around 3-4 seconds and after that Colyseus client freezes and receives no messages from server or client have no resources to decode them: print in room.lua:38 in

 self.connection:on("message", function(message)

works only 3-4 seconds.

Where can I tweak or optimize my system to solve this perfomance issue?

1 Like

Is the game still running (ie animations playing etc) or is the whole app frozen?


game is still running without FPS problems

Oh, well, not sure why then. Perhaps @endel has some ideas on how to best debug connectivity issues?

Btw, @nik.dreml have you created an issue on the Colyseus Defold GitHub page?


No, I’ve created only topic on Colyseus’s forum, I thought it can be my mistake or misunderstanding, not Colyseus’s issue.
Now I’m going to create a issue on the Colyseus Defold GitHub page :slight_smile:

1 Like

@endel can you advise something?

Hi @nik.dreml, do you mind providing an example where I can see the issue happening? Would be easier to inspect the problem this way. Thanks!


Yeah, of course, I’ve sent you a PM.

1 Like

I see many different questions about Colyseus and Defold in various chats/places. And looks like very little lands on the forum. So I’ll try to collect that scattered experience and I inspire others to copy/paste useful bits to the forums, so it is searchable to others.

Here’s a nice chat from Defold’s slack:

totebo [11:00 AM]
Has anyone here had experience with the Colyseus multiplayer server?
sven [11:01 AM]
Not yet, I want to try it but haven’t had the time
Looks promising though!
evangelist [11:03 AM]
guess @SelimAnac is an expert: Colyseus - Tic Tac Toe Multiplayer Example
also @cytherabbit poked around it, to my knowledge
Selim Anac [11:14 AM]
@evangelist @totebo not an expert :slightly_smiling_face: Just made some tryouts with it. Feel free to ask anything, I’ll be glad if I can help.
totebo [11:16 AM]
Thanks guys! I’m researching the possibility of creating a four-player turn based game. Is Colyseus the closest to a plug-and-play option for Defold currently? (edited)
totebo [11:19 AM]
@Selim Anac How well does Colyseus handle multiple servers and scalability?
Selim Anac
[11:21 AM]
Yes Colyseus is very very closest to a plug-and-play. It is easy to use. It is a practical solution for a small size games. (edited)
totebo [11:22 AM]
Nice! I’m looking for a solution that can SCALE if needed, though. :slightly_smiling_face:
Selim Anac [11:23 AM]
It can scale but honestly I don’t recomended it for large projects.
Server - Colyseus v0.9.x
Documentation for Colyseus Multiplayer Game Server for Node.js
Presence - Colyseus v0.9.x
Documentation for Colyseus Multiplayer Game Server for Node.js
totebo [11:24 AM]
That looks good, similar to a solution I used for No Brakes io. Is the reason you can’t recommend it the single point of failure? Or something else?
britzl [11:31 AM]
@Selim Anac Why don’t you recommend it for large projects?
Selim Anac [11:33 AM]
First of all it is a Node.js app :smile: (edited)
It is expensive to use on server side.
Defold version of Colyseus is using a msgpack-lua algorithm cause frame drops: Colyseus - Multiplayer Game Client & Server
Which is why I’m working on C++ NE with threads for handling websocket connection and binary serialiation.
(expensive because of the cpu and mem usage)
I didn’t test it’s scaling features.
So I can’t say anything about it, sorry.
totebo [11:38 AM]
The frame drops is mainly because it’s a synchronous game? The one I’m planning to make is asynchronous.
Selim Anac [11:44 AM]
I think so. Heavy realtime calculations may cause this issue. It may suit well for asynchronous game.
Your game’s logic is very important there. If it is a puzzle game… like a word game, you can do whatever you want. Colyseus with Defold is more than enough for it. (edited)
But if you are planning something like this: Family Age
You can’t handle it with Colyseus. Actually you can, but your server costs go higher and higher.
Selim Anac [11:58 AM]
One more thing; there isn’t build in matchmaking solution in Colyseus. It has matchmaking cycle but you should implement your logic. Matchmaking is a totally other and complex subject
totebo [11:58 AM]
Ok great info.
The game I’m making is for Facebook Instant. So I think I can let Facebook deal with that.
Selim Anac [12:01 PM]
Ah this is great. But highly recommend to test it is performance first. Html build in FB Canvas may cause other problems.
A specially on mobile


Hi everyone! I’ve recently released version 0.11 of Colyseus. with improved match-making! The performance issues have been improved a lot since the new serialization algorithm has landed too!



Great! Thank you! :smiley:

1 Like



Congratulations @endel!


Thanks @britzl! This is going to be great for the sustainability of the project <3


That’s great! We are holding Colyseus deep in our hearts! :heart: If you will need any help, please let us know! :wink:


I am interested to use one of the multi player servers that support Defold for my next game…

I downloaded the tictactoe example from here…

I am using windows 10 and chrome browser
I run the server… it says Listening on ws://localhost:3553

Then I run the defold project twice using Build HTML5…

Both tictactoe windows appear but just say waiting for opt and the server windows stays the same… I have disabled my firewall.

Can anyone give me an idea why it doesnt work ?


Hi @Tremor_Blue, that tic-tac-toe example is a bit out of date, unfortunately.

I recommend having a look at the colyseus-defold project on GitHub, as it has an integration demonstration there.

  • The server/ directory has the Node.js server, you can install the npm dependencies and run npm start to have the server running locally on your machine for development.
  • The example/example.script is the main file for the project, and contains the common usage for a Colyseus+Defold integration. You can see the logs in console, and try out yourself!

Hope this helps! Let me know if you have any questions, cheers! (Feel free to join Colyseus’ Discord server if you want to as well!)


Hi @endel,

Thankyou for your response.

I installed node.js
Downloaded the colyseus project
ran npm install and npm start in the server directory…

That gives…this screen which indicates the server is listening…

A normal build CTRLB fails to connect…

I then run Project\HTML5 Build…

The server seems to recognise that something is going on .

The client shows this screen… I have the console (F12) showing and when I press the logo I see the red errors

What is the demo trying supposed to do… Looking at the code … join a room… send a message…etc.

It would be nice if …How to run the demo and what is expected to happen was presented in the readme file. Perhaps an FAQ.

I am guessing that it is supposed to do more than what i have seen. It seems there is a lot of previous knowledge assumed of the user.

I will as you suggest try on the discord server.