Jump to content

mmorpg advice?


SomeT
 Share

Recommended Posts

I have purchased panda 2 and impactJS (still waiting on license / download links after buying not even sure if its still active?) I want to make an mmorpg, the question I have is, is this possible using a php backend? I see elsewhere on the internet people push more for a javascript backend, but would that not depend on the needs from the complexity of an mmorpg?

Link to comment
Share on other sites

Yeah, your thoughts are totally correct. Use any language you like on the back-end. You have to use JS on the front-end (or transpile to it) but on the server use whatever you're comfortable with.

Most people here are really comfortable with JS so it makes sense to use the same tech across the stack, if you (or your team) are equally happy in other languages then use what you like.

The only place where there is an advantage to use JS everywhere is for universal (or isomorphic) apps where having the exact same code run on client and server is advantageous, if this is a requirement then re-writing algorithms in 2 languages is a painful overhead. However, for your use-case this probably isn't a concern.

JS is quite an attractive case when your logic doesn't require super-high efficiency (JS is interpreted so isn't the fastest) but any perf is IO-bound, which is usually the case when you're pinging lots of messages around. Many of tech open up separate threads for requests whilst JS is single-threaded and for very short lived connections the overhead of opening threads isn't worth the advantages so a language with a tight event loop (such as JS) sometimes actually comes out on top.

Link to comment
Share on other sites

4 hours ago, mattstyles said:

JS is quite an attractive case when your logic doesn't require super-high efficiency (JS is interpreted so isn't the fastest) but any perf is IO-bound, which is usually the case when you're pinging lots of messages around. Many of tech open up separate threads for requests whilst JS is single-threaded and for very short lived connections the overhead of opening threads isn't worth the advantages so a language with a tight event loop (such as JS) sometimes actually comes out on top.

JS is JIT-ed where possible. NodeJS uses V8 engine (same as chrome), and is usually not much slower than well written cpp.

The single vs multi threaded approach – there's high overhead with switching threads (not to talk about cache invalidation), which causes the issues. You can handle a lot of connections on single thread, so the new NodeJS based servers like nginx actually perform better than old school multithreaded apache.

Link to comment
Share on other sites

I mean really, I am trying to figure out my stack and environment setup here, ideally, I want PHP on the backend, it looks possible to do a good mixture of Socket.io, redis and laravel I think....  I thought about starting it off basic as a chat app and scaling it upwards like that.

Link to comment
Share on other sites

5 hours ago, Antriel said:

JS is JIT-ed where possible. NodeJS uses V8 engine (same as chrome), and is usually not much slower than well written cpp.

I think we need to be really careful with statements like this. Anything cpu bound and node (being JIT and dynamic) will struggle. Anything io-bound and node performs well. JS (and bare in mind I love JS) is easy to pick up but doesn't help in larger teams or as application complexity grows, and in no way is in 'safe' in the same way other languages are out of the box (C doesn't count here either!).

Benchmarks are pretty fraught with danger as they often (despite best efforts) don't model actual use cases.

http://attractivechaos.github.io/plb/ This one is incredibly favourable for V8 node (note you can use Chakra or other engines with node if you like) but does show the usual trend of C-like/Java-like/JS/Python/Ruby in terms of average perf (in no way is raw performance a sign of a language's usefulness for most use-cases).

https://benchmarksgame-team.pages.debian.net/benchmarksgame/which-programs-are-fastest.html this comparison is much deeper (explore the site, very interesting stuff) but shows the same rough hierarchy as above:

C/C-like/Rust

Java/Go/Swift then Haskell/OCaml etc

---> there's quite a jump to the next langs

JS

PHP/Hack/Erlang

Ruby/Perl/Python then Lua

If you know anything about how these languages work this is no surprise, with the exception of JS which generally performs way better than expected (or, maybe should be expected as it has a monopoly over its execution environment which has seen extensive work i.e. V8, Chakra, SpiderMonkey etc). 

Note that the first two groupings above are fairly close, the next 3 are all fairly separated in terms of perf, big jumps between each group (the y scale isn't uniform in the graphs in the above link, there is a MASSIVE difference between say, Java and PHP, or, as mentioned here, between C and JS).

Note also that TypeScript is an entry in the above linked graphs, this is odd as it has no runtime, there's probably a reason for this (and why its long-tailed) but it might be that JS engines can optimise better based on the transpilation of TS to JS in these test cases.

Note also that poorly written C could very well be slower than expertly written Ruby (for example).

5 hours ago, Antriel said:

so the new NodeJS based servers like nginx actually perform better than old school multithreaded apache.

nginx isn't node. its written in C as its core requirement is performance (and likely other reasons too). https://github.com/nginx/nginx

5 hours ago, SomeT said:

I mean really, I am trying to figure out my stack and environment setup here, ideally, I want PHP on the backend, it looks possible to do a good mixture of Socket.io, redis and laravel I think....  I thought about starting it off basic as a chat app and scaling it upwards like that.

Absolutely nothing will stop you building what you want with PHP. Personally I don't think its a natural fit, neither is Laravel (my knowledge here is limited), but, its a flexible and powerful language and if you're comfortable with it, you'll get it to do what you want. Certainly you'll do it quicker than learning a new language or new patterns/modules/libraries to use that language.

Link to comment
Share on other sites

Devs like a Node implementation for server side processing of mmo projects because Node typically handles that type of traffic much more efficiently than a standard LAMP stack server. PHP will get the job done but if your game becomes very popular then your server costs will likely rise much more quickly than if you had chosen Node.

Link to comment
Share on other sites

8 hours ago, mattstyles said:

nginx isn't node.

Right, yes, thanks for correcting me. I mainly meant event-driven/non-blocking as opposed to multi-threaded.

I agree with the rest, I only pointed JIT out because saying JS is interpreted and slow seemed like too big an oversimplification.

4 hours ago, SomeT said:

I actually have heard that if you program PHP well server side it can just be as effective, but that comment might be somewhat naive?

I have no late experience with PHP, but I doubt that. Compared to JS it has much less support which will mirror itself in available libraries and community help. That said, it doesn't much matter what you start with. It's quite possible you will need to change your environment a few times as you requirements and design changes.

Starting with the basic requirement: a WebSocket server, you might find out the ones for PHP aren't as fast as you need and might need to find something better. But that doesn't mean you can't start with what you know now.

Link to comment
Share on other sites

Quote

I actually have heard that if you program PHP well server side it can just be as effective

That seems doubtful, but it would be interesting to see. At the least, you would want to use a LEMP stack, rather than LAMP, to maximize traffic throughput. PHP and JS are both interpreted languages, but Node's JS runs on the V8 engine which is super fast. I would be shocked if a JS script running on V8 didn't blow the doors off an equivalent PHP script running on the fastest available PHP engine.

But as Antriel stated, starting with PHP is not necessarily a bad idea if it will let you cobble together something to try out more quickly and easily. Just keep in mind a PHP solution will not scale as well, so you may need to switch to a Node solution if your game becomes successful in order to keep server costs down.

Link to comment
Share on other sites

I have decided on MEAN stack with BabylonJS in 3D now seems like a good option. I usually use LEMP with PHP tbh, Apache does not usually work well with my PHP code so I tend to prefer LEMP. I think really it depends what you are building, I can't see a full scale game working now in PHP after much research and this post (unless someone can prove me wrong?) so yeah MEAN stack and BabylonJS it is.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...