Jump to content
  • Advertisement

Recommended Posts

well, i have started developing games last year, alone , I made a singleplayer 3d openworld rpg on unity you can look at it on googleplaystore ( kooru stone rpg ) whatever, this year, i wanted to make mmo, which gone really fine until I first try real hosting, I was working on "wamp" until then. The reason i am desperate now is that the way my game works.

On my pc, using wamp mysql , with localhost as host for my game, i was testing my mmorpg with using andorid emulators, ofcourse no lag no issues no restrictions, beautiful dream... But then, I wanted to get real host from web, so, I rent a basic, cheaphest ever web host ( 10$ year ), and transferred my php files along with sql database. 

So, I launched the game, still no issues, tried to handle 2-3 players by using my pc, phone, friend's phone...  

After a while, ( after really short time (3-4mins)) host started not to respond, beacause those web hosting were not fit to handle mmos, i predicted that.

now what i am explaining is that my game works like this and asking what way should i use to handle it :

- Creates web request ( like : webhost.com/game/getplayerdata.php?ID=2 )

-Reads request ( request result be like = "ID2-GoodGuyXx-23-123-4-123-43 )

-Builds player using result string

-does similar requests REEAALY FREQUENTLY  ( total requests of 8 - 12 times per seconds )

With my current ultimate cheap web hosting, i can handle 2 players with low lag ( lol ) but, i want to handle around 20-100 players,

just need a clear path, i have been struggling with google cloud sql and other vps server dedicated server options, i dont wanna pay much and get ripped off.

Edited by Mert Oguz

Share this post

Link to post
Share on other sites

Is there a reason you just don't use the Unity multiplayer services? It works almost automatically with Unity games.

I find it much easier to use than what I am trying on my own. They also have a handy way of calculating your cost:


2 hours ago, Mert Oguz said:

-does similar requests REEAALY FREQUENTLY  ( total requests of 8 - 12 times per seconds )

Aren't you in control of this?

The way I do my own requests, still learning, is by sending one large pack with the main info when the player starts. Then I update only the data that is needed.

This works better than updating at a fixed time period for me.

Share this post

Link to post
Share on other sites
10 minutes ago, Scouting Ninja said:

Is there a reason you just don't use the Unity multiplayer services? It works almost automatically with Unity games.

I generally dislike unity servies, assets, libraries and components. I mostly force myself to build my own path.

11 minutes ago, Scouting Ninja said:
2 hours ago, Mert Oguz said:

-does similar requests REEAALY FREQUENTLY  ( total requests of 8 - 12 times per seconds )

Aren't you in control of this?

I am in control of limit of it, requests sent over time from request queue, not when needed. Im fine with it but minimum request for a second is theorically 8, if connection is perfect, players sends it's 32-character length basic data for 4 times and gets character list of basic datas 4 times.

Share this post

Link to post
Share on other sites
1 hour ago, Mert Oguz said:

32-character length basic data for 4 times and gets character list of basic datas 4 times.

This looks like it can be your problem then. 32*2 = 64 bytes for the string. 64* (8 to12) = 512 to 768 bytes per second.

Most of these cheap servers have a 500 bytes per second limit for each user. You should also have a huge overhead because your not using a server optimized for games.


"ID2-GoodGuyXx-23-123-4-123-43 "  Looking at this example you waste a lot of data on the ID, around 50% of the data is just the ID.




You could use a shorter ID here. A number would be more efficient. ID2-GoodGuyXx = 9999999999999; so nine billion players support for the same cost. You could even improve that by just using the ACII numbers. (A-Z, a-z, 0-9 and sybols)

128*128*128*128 = 268 435 456 IDs for just 4 string characters. A example would look like this (B1&b) and would be 8 bytes large.


The rest of the data your sending looks like values for resources. "23-123-4-123-43" You could again send these as the ACII number




"23-123-4-123-43" = "W{D{+"

To read this you use:

string StringCode = "W{D{+";
foreach( char Resource in StringCode)
   int tempInt = Resource;

Don't parse it, that will not work, you need to turn it into it's int.


So if we use both optimizations we get: "B-W{D{+"  = User 002 has 23 123 4 123 43

7*2 = 14 bytes = 14* (8 to12) = 112 to 168 bytes per second.

So with this you should be able to connect players without breaking the limits of your small server.


For even more ways to pack data here is links:

https://gafferongames.com/post/reading_and_writing_packets/ given by @Kylotan

https://www.gamasutra.com/view/feature/131503/1500_archers_on_a_288_network_.php given by @Hodgman

In this topic:




I just want to point out that running your game with Unity's services would cost $30.

Edited by Scouting Ninja

Share this post

Link to post
Share on other sites

well the way you take it really impressed me, I was thinking of compressing the data latetly but I didnt think of using characters for numbers, , I may, mess it up a lil bit while working on this since there are some high/negative numbers but still when in numbers it doesnt excess 32 char limit in the end its fine.

um so... 10 $ -year host to handle mmo challenge accepted ?

lol not really since i am even getting lazy start connections on mainmenu.

just a "better but not best" web host can handle this i believe?

thanks so much for replying me and pointing an essential issue, I will do my best with data compressing. 

Share this post

Link to post
Share on other sites

-does similar requests REEAALY FREQUENTLY  ( total requests of 8 - 12 times per seconds )

I think this is the problem. Trying to use MySQL as a messaging layer is extremely inefficient. Cheap web hosts have thousands of people share the database, and trying to add more queries will not work. I don't think bandwidth is your main problem.

First, you'll want to use a real web host. You can use Amazon Lightsail for $10/month, or Linode for $10/month, or something like that. You will have enough CPU power and memory to run small servers on those hosts under your own control. You will also get enough network bandwidth that you don't need to worry about that as a limitation.

Second, you may be able to get to 10 players on such a server using the mechanism you have; you may even be able to throw more money at it and get to 100 players using MySQL (at potentially hundreds of dollars per month per server.) But that's a waste of money.

You'll want to use a server that doesn't need a database to answer most questions. The way to make that happen, is to use a server stack where the server has memory and persistence. PHP doesn't do this, but servers like Node.js or golang do (as well as Java, C++, C#, and other such languages.) You can also get persistent servers in Python. You can still use HTTP for your protocol -- it's not very efficient, but it can be made to work. (Websockets would be better.) But, make the queries go to data in RAM, and respond based on data in RAM, rather than the database. Instead, only read from a database when the player first logs in, and write back to the database when data that really matters changes (inventory change, trade, experience gain, those kinds of things.) This will keep the database much less overloaded.

64* (8 to12) = 512 to 768 bytes per second. ... Most of these cheap servers have a 500 bytes per second limit for each user.

I doubt this is accurate information. Each web request will have more headers than just the request URL, and each response will have a lot more headers than just the payload data. And I've never seen a cheap web host that intentionally limits the bandwidth per user, although they sure do oversubscribe their network interfaces, so how much data you can get through depends a lot on how busy other users on the same host is.

I highly recommend starting with a virtual private server from Lightsail or Linode or Dreamhost VPS or Interserver, and you have the ability to scale up from there.

Share this post

Link to post
Share on other sites

I have reduced those calls from the game to 3-5 times per second, i have made my all web requests on a single queue that whatever you do, its send when queue clock in up to ready for that job. ( that means, in worst case, player can send 5 requests max in a second ) I have tried to login the game from 4 diffrent devices and it was fine but lil laggy. ( even lags when playing solo though lol )

I am sure that i need to manage those stuff definetly not with a web hosting service. Also I asked to my web host tech service that" Just after i bought the service, there was no issue with connections( no lag) i am building an application that is used from mobile android devices so if this service does not fit what should i do?"

And they replied back like, "you cant use it from applications its not supported, try cloud servers"

If somebody knows what does that mean? What i am saying is I can currently play the game actually with 4 players, and even right after I transfered my game to their host, connection was almost perfect. Do they put a connection barrier ? So if i get a non-shared web hosting, will i be able to handle the game actually?

I would really like to change the way my system works though, i have worked on a firm that makes trading web sites with asp.net using c# but for mmo, i looked up on web and i thought it could be light and fast to choose php mysql. I am totally noob on this stuff. 

And to prevent "cheat engine-like" hacking i have made restrictions on requests so players wont be sending their data from client to update directly, there are some extra queries in php files to first find player with account id then compare some stuff. Maybe that also could be the reason of slow responds.

Currently the happening thing after player enters to the map is,

1) loads everyone in the same instance, with their main and basic data "once". 32+32 strings for each player ( will compress that soon )

2) every 0.3 seconds, updates your basic data along with loading others basic data. 

3) after each '4 basic updates', runs a check instance to look for dates(32 string each player) wheter someone entered or left or disconnected.



Share this post

Link to post
Share on other sites
7 hours ago, hplus0603 said:

And I've never seen a cheap web host that intentionally limits the bandwidth per user,

Sorry if I wasn't clear on that. I didn't mean the host limits the bandwidth. I meant that the allowed bandwidth / players. Also I know it isn't as simple as that; that is why I mentioned the overhead for servers that isn't made for hosting games; all though I don't exactly know what it is.

I am really new to this.

7 hours ago, hplus0603 said:

First, you'll want to use a real web host.

Could you explain the difference between web host like Amazon Lightsail and others. I think many of us new to multiplayer games end up paying for the wrong services.

Share this post

Link to post
Share on other sites

If somebody knows what does that mean?

They seem to claim that they only expect you to make web pages on their service, and any kind of application/web service that makes API calls are unlikely to work well on their service.

Could you explain the difference between web host like Amazon Lightsail and others

There are "shared web servers" -- these are the cheapest, and is the kind that the OP initially set up.

These give you a directory to upload your web files to. Those web files might be intended for some particular web development language (PHP, Ruby, Python, etc) and typically use a "one request is one process" model. You receive a HTTP request, you do whatever queries and processing you need to do (if any) and you respond with a web page or some other web resource (image, XML, JSON, ...) You cannot upload code that's not supported by the web server host -- you can't build your own C code for processing network requests -- and you cannot run processes that stay alive for longer times, talking to many players at the same time.

These are okay for "my own photo album" or "jimmy's pizza ordering page." If the page sometimes takes a second or two to load, that's not a big deal. All the traffic goes over HTTP,  which is a request/response, bulk transfer protocol on top of TCP,  with no particular guarantees around latency. Also, typically there are 1000s of "home directories" on each of these servers, serving a bunch of different, small, web pages all at once. (The server knows which directory to look in based on the URL and Host: header in the HTTP request.)


Then, there are "metal servers" -- a computer is plugged in to the network, and has an OS on it, and you get administrator/root access. It's up to you to make sure the hard disks are partitioned the way you want them, that the software you need to run on there is installed, and that security exploits get patched. You can build whatever software you want and install on these servers. For action games, which almost always use UDP networking, this is great, because you can spin up a game server on a known port, and point game clients at this server/port. Draw-backs are that you need to be much more aware of how to administer servers in a safe, secure, and efficient manner.

In addition to game servers, web sites that are bigger than suitable for a shared web host can use one of these servers (or more) and install their own web server and database server as the software that runs on these servers. This allows you to avoid the "noisy neighbors" problem of shared web hosts.

Because these servers are a full computer that costs a lot of money to buy, server hosting companies will charge significantly more per server instance. Typically a few hundred per month, at least (more if you want fancy memory / RAID disks / multiple CPUs and so on.)


Then, there's an intermediate step. You don't need a big server with 256 GB of RAM and a 10 TB flash RAID array and dual 10 Gbps uplinks to the router. You just need some fraction of that -- one or two cores, one or a few gigabytes of RAM, a dozen gigabytes of disk space for your software, and a terabyte or two of network transfer per month. You're OK with sharing the same physical hardware with others, as long as you get the guaranteed memory and processing power that you pay for. Various "virtual private server" ("VPS") solutions deliver this kind of server. For most intents and purposes, it "looks like" a small metal server (and has some of the same problems of needing security patches, administration, and so forth,) but the cost of actually sticking hardware in a rack in a data center is spread across many people who each share a defined portion of the server. Thus, this is cheaper per month than a full server.

This is what Amazon Lightsail, Linode, Dreamhost VPS, and Interserver end up selling you. Amazon has the best name in the business and the most mature set of infrastructure tools, and thus charges the most. Dreamhost has a business that's more around easy-to-manage web sites, and provide a lot of value-add if you use their software versions, and thus charge extra for that. (They also have shared web hosting.) Linode gives you a little more than Amazon for your money, while having a smaller variety of tools around their images, but are still a well-known actor with some really big customers. And, finally places like Interserver is just "give me a server and get out of the way" bare bones, which lets you get down in price a few more dollars at the bottom end. On the other hand, their data centers and internet uplinks are more oversubscribed than Linode or Amazon -- you get what you pay for.

There are of course many more online server providers of various kinds -- Heroku, 1and1, Peer1, ServerBeach, Rackspace, and the list goes on. The four above are the ones that I have direct experience with that has been good enough to recommend if you need their particular kind of service.


Once you outgrow VPS/cloud solutions and metal-leased servers, you will build your own data centers in some co-location facility, negotiate for bandwidth with upstream providers like Cogent and Level3, and screw your own servers into your own (rented) racks, where you have to build your own in-datacenter network infrastructure (routed or switched? Overprovisioned or nonblocking?) and have to worry about things like power density (130W CPUs perform great, but if you try to cram two of them per motherboard times 42 of them in a rack, you will draw more power than most power distribution and cooling will let you get away with -- are watercooled racks worth it?) Co-location is cool and all (or, if you're facebook/google, you build your entirely own data centers) but very few indie games grow to the point where they need to worry about that. Find a VPS vendor you can trust (linode or amazon) and stay there for as long as you can.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
  • Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Gnollrunner
      Hi again,  After some looking around I have decided to base my game directly on Direct X rather than using an existing game engine.  Because of the nature of the stuff I'm doing it just didn't seem to fit very well and I kept running into road blocks.  At this point I have a big blob of code for doing fractal world generation and some collision code,  and I'm trying to put it into some form that resembles a game engine.  Since I've never used one before It's a bit alien to me ..... so can someone direct me to a book, website, article, whatever... that covers this?  I'm mainly looking for stuff that covers C++ library design. I'm not adverse to using 3rd party tools for stuff I can used them for.
    • By Atwo Studios
      Hello everyone this is Anthony from Atwo Studios, as small indie company we have published 2 indie games using Game maker, one being ROY - Color Matching and the other being Solar Switch. Both can be found on iOS and the Google play store.

      For our third indie game we are wanting to make a golf puzzle based game, this would be on mobile too.

      Our current team consists of a designer,programmer and artist. I would like to add a person who is interested in making sounds effects/ music for our game.

      If you are interested in creating a game for portfolio work or just as a hobby, 
      please send me an email at : anthony@atwostudios.com

      PLEASE do attach any audio work so that my team and I can review it and determine if you are qualified for what we are looking for.

      Please check out our website for more information about us and the types of games we have made so far.
      p.s. I am not a website designer
    • By mapmip
      Hi, I am fresh to database design, recently trying building my mobile multiplayer game, it will be something like pokemonGo.
      I have experience on MySQL, and I know some NoSQL engines like redis.
      I saw some existing game projects which store their data on both SQL database and noSQL database.
      Could anyone give some advice that what kind of data should store in SQL and what kind of data is better to be in noSQL.
      It would be nice if giving some real scenario examples.
      My understanding is data like user profile, purchase transactions should be in SQL.
      Field map information, enemy status can be NoSQL.  
    • By ethancodes
      I've got a bug with my brick breaker style game. The bricks move down one line at a time ever 1.5 seconds. What appears to be happening is occasionally the ball will be just about to hit the brick when the brick moves down a line, and now the ball is behind it. I'm not sure how to fix this. I have two ideas but I'm not sure of implementation. 1 solution would be to check where they were and where they are going to be before rendering the frame. Then if they crossed paths, then register the brick as hit. Solution 2 would be change how the bricks move. I could maybe slide them down line by line, instead of a jump down. I'm not sure of this will fix the issue or not. Any ideas?
    • By mmmax3d
      Hi everyone,
      I would need some assistance from anyone who has a similar experience
      or a nice idea!
      I have created a skybox (as cube) and now I need to add a floor/ground.
      The skybox is created from cubemap and initially it was infinite.
      Now it is finite with a specific size. The floor is a quad in the middle
      of the skybox, like a horizon.
      I have two problems:
      When moving the skybox upwards or downwards, I need to
      sample from points even above the horizon while sampling
      from the botton at the same time.  I am trying to create a seamless blending of the texture
      at the points of the horizon, when the quad is connected
      to the skybox. However, I get skew effects. Does anybody has done sth similar?
      Is there any good practice?
      Thanks everyone!
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!