Please check out Aarchon !

Member Discussions

terms



[Previous] [Next] [Post] [Reply] [Topics] [Summary] [Search]


1. Server within PHP Sat May 15, 2010 [9:54 AM]
Scorpion
Email not supplied
member since: Oct 27, 2001
Reply
I've written a very basic server within PHP (CLI) with MySQL for storage, however I'm questioning my choice of language for this. The reason why I chose the language was for speed of development, PHP makes development extremely fast. I've written it to run on a 4 ticks per second basis like you'd expect from a Diku mud.

However, PHP doesn't support multi-threading so I'm thinking that this language will not scale very well, especially when there would be thousands of NPCs, pathfinding with some basic AI.. and ofcourse, keeping the database up to date to name a few of the (most likely) demanding features. My aim is to also be able to support in the thousands of players online, not just a handful (I know people will probably comment on that, but it's important to be able to scale).

My thoughts are to start porting it over to C++, but before I start doing that I'm asking on here for some feedback. I wouldn't want to take the time to port it over if PHP is capable of running the server with a decent speed.


2. RE: Server within PHP Sat May 15, 2010 [10:46 PM]
mann_jess
Email not supplied
member since: Dec 10, 2005
In Reply To
Reply
A couple points:

1) You're right. PHP isn't generally the right choice for this sort of project. If you'd asked me before you started, I'd prolly have suggested to look into other options. However, that doesn't necessarily make it not the right choice for your project, which you're developing.

2) While PHP doesn't currently support threading, you have other choices. For one, take a look at the process control functions. These will require your code to be structured differently than a threaded app, but functionally it won't be all that different.

3) Threading and scaling are two separate discussions. PHP isn't a super fast language out of the box, but there are numerous ways to optimize which do make it sufficiently fast to handle the requirements of any large MUD. Specifically, take a look into opcode caching. xcache is a good place to start. Data caching will also be important, which can be done with xcache, or (if you decide to cluster) memcache.

In short, don't feel pressured to change just because everybody else does it differently. PHP can handle your needs just fine. It'll just take a bit of knowhow to optimize as you grow. If you have any questions, post to a PHP forum for help.

Good luck,
-Jess

(Comment added by mann_jess on Sat May 15 23:50:23 2010)

Also, if you don't know C++, then don't learn it just to port your code. Python much more similar to PHP, generally faster, quick to develop, and supports threading. A compiled language is an optimal choice everything considered, but not if you have to learn it as you go; You'll just end up tossing all your work down the road once you realize how stupid your early learning-the-language design was. =p




[Previous] [Next] [Post] [Reply] [Topics] [Summary] [Search]