Sign in to follow this  

[web] Background processing of data

This topic is 2851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a question regarding web browser games. You have seen many games, that has some income stuff, that enables you to make some resource income, you build something, you have steady income, for example, 5 points of gold, and at the same time, we have a possibility, to look at other people accounts and see their current gold. That means, we need some bacground process, that is doing, like every second, run through all database, and adding those 5 points to some data field. What happens when we have 1000 users, maybe 10 000. That makes a big load for server. What happens, when we want to add 10 different values to 10 different data fields, that are calculated from 30 different other fields in database, and we want to do that for each user of game? I don't understand, how they manage to get all of this working, in all of those broswer games around. Maybe there is some special way to do that and that is not time consuming? maybe some algoritm, that calculates those values only then, when another user is asking for it? Please, share your knowlage about this process.

Share this post


Link to post
Share on other sites
An approach I've seen suggested before is to just timestamp the data in the database. You only perform global updates when someone loads a page.

So on page load:
find timestamps that are old
update the values by the total delta time that has passed since last update

The alternative is a chron job script that does this for you. What you are talking about is very trivial addition/subtraction/whatever. As far as CPU load is concerned the total update could probably be done millions of times a second.

-me

Share this post


Link to post
Share on other sites
You're talking about an MMO. There is no "easy" way. Use the DB to do the hard stuff, if you can:


update userdata, userproduction set
userdata.resource = userdata.resouce + userproduction.production

Share this post


Link to post
Share on other sites

This topic is 2851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this