Share Objects(resources) between multiple php threads

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
nathanr
Forum Contributor
Posts: 200
Joined: Wed Jun 07, 2006 5:46 pm

Post by nathanr »

I'm thinking a daemon rather than a php app would be more suited :D just the thinking we all love at the end of a project
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

feyd wrote:memcache and shmop may be of interest.
True, but it also sounds like something as simple as an SQLite database on a RAM disk would do the job as well. The Share Nothing style is to use standard tools and standard methodologies to solve problems. It also implies that the solution to a performance problem is rearchitecting ... not building a bigger, rocket powered hammer.
(#10850)
john2496
Forum Newbie
Posts: 7
Joined: Sat Jul 28, 2007 7:39 pm

Post by john2496 »

I did some tests and I realized that even if I could communicate between threads, php is slow. Really slow, its great for web apps but not for servers :(. For example, in the game there are literally hundreds of game objects that need to be updated once a second. Php takes over 27 seconds to do a simple loop through an array of objects and call the update() method on each one. The processing involved in updating the entities calls for nothing more than a few simple conditionals (pulled from local vars, no db stuff or anything) and sometimes simple math (no floating points).

I'm almost done porting the server into java and use memcached for communication betwen the php client & js server. :)
Post Reply