PHP MYSQL MMORPG

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 Advertisement 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. Solve: Spoiler 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 Solve: Spoiler "23-123-4-123-43" = "W{D{+" To read this you use:  string StringCode = "W{D{+"; foreach( char Resource in StringCode) { int tempInt = Resource; print(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: In this topic: Edit: I just want to point out that running your game with Unity's services would cost$30.

Edited by Scouting Ninja

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 Quote -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 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 )

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 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 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.

Create an account

Register a new account

• 11
• 16
• 11
• 13
• 11
• Similar Content

• Hi everyone! I've developed a game called The Last Dog (ZOMBIES + DOGS) and was wondering if you could give it a try in order for me to analyse your behaviour in analytics. Give it a shot! Please download it here: https://florsyl.wixsite.com/thelastdog2 and let me know if you detect any bugs. VIDEO.3gp

• Hello fellow devs!
Once again I started working on an 2D adventure game and right now I'm doing the character-movement/animation. I'm not a big math guy and I was happy about my solution, but soon I realized that it's flawed.
My player has 5 walking-animations, mirrored for the left side: up, upright, right, downright, down. With the atan2 function I get the angle between player and destination. To get an index from 0 to 4, I divide PI by 5 and see how many times it goes into the player-destination angle.

In Pseudo-Code:
angle = atan2(destination.x - player.x, destination.y - player.y) //swapped y and x to get mirrored angle around the y axis
index = (int) (angle / (PI / 5));
PlayAnimation(index); //0 = up, 1 = up_right, 2 = right, 3 = down_right, 4 = down

Besides the fact that when angle is equal to PI it produces an index of 5, this works like a charm. Or at least I thought so at first. When I tested it, I realized that the up and down animation is playing more often than the others, which is pretty logical, since they have double the angle.

What I'm trying to achieve is something like this, but with equal angles, so that up and down has the same range as all other directions.

I can't get my head around it. Any suggestions? Is the whole approach doomed?

Thank you in advance for any input!

• Hi,
I am a CAM developer working with C++ and C# for the past 5 years. I started working on DirectX from past 6 months. I developed a touch screen control viewer using Direct2D. I am working on 3D viewer currently. I am very slow with working on Direct3D. I want to be a gaming developer. As i am new to this i want to know what are the possibilities to explore in this area. How to start developing gaming engines? Is it through tutorials? I heard suggestions from my friends that going for an MS helps. I am not sure on which path to choose. Is it better to go for higher studies and start exploring? I am currently working in India. I want to go to Canada and settle there. Are there any good universities there to learn about graphics programming? Sorry if I am asking too many questions but i want to know the options to choose to get ahead.
• By devbyskc
Hi Everyone,
Like most here, I'm a newbie but have been dabbling with game development for a few years. I am currently working full-time overseas and learning the craft in my spare time. It's been a long but highly rewarding adventure. Much of my time has been spent working through tutorials. In all of them, as well as my own attempts at development, I used the audio files supplied by the tutorial author, or obtained from one of the numerous sites online. I am working solo, and will be for a while, so I don't want to get too wrapped up with any one skill set. Regarding audio, the files I've found and used are good for what I was doing at the time. However I would now like to try my hand at customizing the audio more. My game engine of choice is Unity and it has an audio mixer built in that I have experimented with following their tutorials. I have obtained a great book called Game Audio Development with Unity 5.x that I am working through. Half way through the book it introduces using FMOD to supplement the Unity Audio Mixer. Later in the book, the author introduces Reaper (a very popular DAW) as an external program to compose and mix music to be integrated with Unity. I did some research on DAWs and quickly became overwhelmed. Much of what I found was geared toward professional sound engineers and sound designers. I am in no way trying or even thinking about getting to that level. All I want to be able to do is take a music file, and tweak it some to get the sound I want for my game. I've played with Audacity as well, but it didn't seem to fit the bill. So that is why I am looking at a better quality DAW. Since being solo, I am also under a budget contraint. So of all the DAW software out there, I am considering Reaper or Presonus Studio One due to their pricing. My question is, is investing the time to learn about using a DAW to tweak a sound file worth it? Are there any solo developers currently using a DAW as part of their overall workflow? If so, which one? I've also come across Fabric which is a Unity plug-in that enhances the built-in audio mixer. Would that be a better alternative?
I know this is long, and maybe I haven't communicated well in trying to be brief. But any advice from the gurus/vets would be greatly appreciated. I've leaned so much and had a lot of fun in the process. BTW, I am also a senior citizen (I cut my programming teeth back using punch cards and Structured Basic when it first came out). If anyone needs more clarification of what I am trying to accomplish please let me know.  Thanks in advance for any assistance/advice.

• Hi , I was considering this start up http://adshir.com/, for investment and i would like a little bit of feedback on what the developers community think about the technology.
So far what they have is a demo that runs in real time on a Tablet at over 60FPS, it runs locally on the  integrated GPU of the i7 . They have a 20 000 triangles  dinosaur that looks impressive,  better than anything i saw on a mobile device, with reflections and shadows looking very close to what they would look in the real world. They achieved this thanks to a  new algorithm of a rendering technique called Path tracing/Ray tracing, that  is very demanding and so far it is done mostly for static images.
From what i checked around there is no real option for real time ray tracing (60 FPS on consumer devices). There was imagination technologies that were supposed to release a chip that supports real time ray tracing, but i did not found they had a product in the market or even if the technology is finished as their last demo  i found was with a PC.  The other one is OTOY with their brigade engine that is still not released and if i understand well is more a cloud solution than in hardware solution .
Would there  be a sizable  interest in the developers community in having such a product as a plug-in for existing game engines?  How important  is Ray tracing to the  future of high end real time graphics?