Jump to content
MakeWebGames

Recommended Posts

Posted

Ok, based off pog1's code www.pog1.co.uk/updates.txt, he made the removal of 5 minute cron's. I attempted to try the removal of 1 minute cron's and worked perfectly.

How this Works

Well, you might be thinking, the user has to click every minute for it to go down? No, it adds up so basicly like this.

If the user is in hospital or jail for 12 minutes and no one clicks in a time frame of 10 minute's. When some one click's the 10 minute's get's deducted. Leaving them with 2 minutes.

Well, let's start off with the querys:

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Now here is the file:

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

You can add pog1's code also inside that file. When calling it out. Just include this under your config code in globals.php where it connects to the DB.

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Enjoy the removal of 1 minute cron's :)

  • Replies 81
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Re: [any version] Removal of 1 minute crons

It shows error's but won't actualy work. No one outside your game can actualy run it. Oh and if you want to stop people viewing the page in domain.

if($_SERVER['PHP_SELF'] == '/file') { die; }

Posted

Re: [any version] Removal of 1 minute crons

yeah, so the server will not be doing unessery things like updating all users stats and it will spend more time loading pages faster

Posted

Re: [any version] Removal of 1 minute crons

I'm gonna add this to my game :)

Also, the limit of integer is sumin like 2.2Billion which is 11 chars in length i think. You have a int(255) which may cause an error, try bigint(52) or sumin.

Posted

Re: [any version] Removal of 1 minute crons

I think POG1 and Haunted_Dawg have revolutionised the life of MCC by doing this to the Crons.

I know from experience not many Hosts like 1 minute cron jobs so gone are the days of having to sift through thousands of hosts that will allow it.

What they have achieved here is an emense step forward for any MCC gamer

So dabomstew get back to the drawing board my son theirs a new clan in town.

EXCELLENT work..

:)

Posted

Re: [any version] Removal of 1 minute crons

Okay very nice of you that you have "recoded" the crons, however this is not something that will increase performance, it will actually decrease performance (slightly) the way it is now. So please be sure that you have a valid reason to add this.

The idea is good, the workout isn't ...

PS: I would only use this method if you do not have a crontab/cron manager, else stay with the old fashioned crons.

Posted

Re: [any version] Removal of 1 minute crons

@illusions. I created a 5min updater months ago, I remember reading posts like "use a timestamp" and decided to try it out.

To increase performance you could instead of adding 12 mins to the jail field add the current time stamp + how long in jail for. Then instead of checking if the field has a value you could use something like

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Posted

Re: [any version] Removal of 1 minute crons

that will not have much of an impact at all, I would more look to your queries, now you are just running your crons each page load (if they are valid by the if statement) for everyone, they will be ran on time, yet it does exactly the same thing as a cron, except here you load an extra file each pageload ;)

but then again, you'll meet another problem (table locking), I might explain that later on.

Posted

Re: [any version] Removal of 1 minute crons

Sorry in advance im catching up on unread posts

I was thinking while going through the various replies that this does seem a little lets say different but it's very good work.

The method maybe a little scetchy but i like it.

Templar pointed out something i was wondering about also, it would run exactly like cron just maybe slower?

a extra file to load would decrease loading speed then say a user is on DSL or something along them lines would it not be easier to strain the server rather than the user since they are basically why the website is there?

If you start to slow your website down im sure not many members will stay when another site will load faster.

All in all i like how people are getting imaginative and thinking outside the box, good idea lads 8-)

 

I didn't have time to research this but am i right in assuming table locking is something to do with various queries being inserted into a table?

like with this you could have 300 people in over 60 seconds inserting at-least 5 queries per second...

Posted

Re: [any version] Removal of 1 minute crons

As i also argued with some one on msn about this.

On every page load, it is selecting 2 row's from one table.

1 row is for the last time and other row is for the time name.

If the last time was 60 second's ago. Perform the rest of the query's. If not don't do nothing.

Basicly if it is not 60 second's no other query's are being performed. Thus leaving it with the 1 query at the top to check the last time etc.

Now let's see. A basic v2 game average querys on page load is what? 6 - 10. And thus selecting every row in that table. What's 1 query with 2 row's going to do with 6 querys of up to 100 row's?

I ran test's of this. And it only add's a 0.00001 time frame to the page load. But let me say this.

I ran the exact same code without the if statement via a cron to log and guess what the page load was? 0.001. So by all mean's i do think this is faster and less resource.

Posted

Re: [any version] Removal of 1 minute crons

users won't notice much since they do not get presented any php code on their plate, that's all for the servers.

The only advantage that you will notice is when you have hardly anyone online, so you don't get any page load within the cron period. But that comes together with having a small user database and also having a cron that doesn't need to overrun 1000s of rows each min to update.

I'm not saying it sucks or anything at all, just saying it's a different method as a cron, but doing the same thing in a different way. Arguing over this 0.000001 second that you have noticed, seems pointless to me. So if you want to add it in for performance... do it ONLY if you have a small userbase, else you will not notice a difference anymore and even loose time. Your test might show a win situation, but I don't think that was a test on a game with 10k rows and 50users logged in constantly?

Posted

Re: [any version] Removal of 1 minute crons

If you are looking at the speed with the 5 min cron it will be a big difference.

In the cron it updates energy, will, brave etc. Updating everyone in the user base will take quite some time. If you have it update per user only when they are online it will be a big difference.

Posted

Re: [any version] Removal of 1 minute crons

Ahh very nice, would this also benifit for doing it half hour, hour and day? Timestamps aren't my best area but i need to learn :wink:

Posted

Re: [any version] Removal of 1 minute crons

Templar, this will benefit a game with around 50 online per 15 minute's. But putting it around TC, won't match. Why do you think TC has a timestamp on per user. TC only matches the user and not the entire website.

Posted

Re: [any version] Removal of 1 minute crons

 

If you are looking at the speed with the 5 min cron it will be a big difference.

In the cron it updates energy, will, brave etc. Updating everyone in the user base will take quite some time. If you have it update per user only when they are online it will be a big difference.

True, but I was actually refering more to killah, not to you, you have a timestamp per user whereas killah doesn't have it. He still is calling in the 1min cron manually, but just in a different way actually, that is what I'm pointing out.

 

Templar, this will benefit a game with around 50 online per 15 minute's. But putting it around TC, won't match. Why do you think TC has a timestamp on per user. TC only matches the user and not the entire website.

Agreed partially, I know what you are trying to do, but I refer to my above :)

And killah is this is what you really wanted to make in the first place, then I don't really get it why you have done that, so I won't argue over it, I'm not going to repeat myself over and over again.

Posted

Re: [any version] Removal of 1 minute crons

I understand at what you get at templar, how ever. This is intentionaly made for mcc game's. Now, how many mcc games has around 130+ online in a 15 minute period?

Not even cronus's game which is the fastest growing mccode game i have seen by far.

 

The most users ever recorded online within 15 Minutes: 72

Now, this being 72 online within 15 minute's. It would be better to use this than the cron.

Now to my specifications and to what i tend to do for my game is. Have it run on per user. Not entire game.

Also i tend to make use of the UNION in mysql.

And i also noticed that yes there is a problem with pog1's code. Have not looked at it yet to fix it.

Posted

Re: [any version] Removal of 1 minute crons

I know not many are getting sky high results, but that doesn't mean you can't do it good the first time, half work is no option ;)

But as long you understand me, I'll be happy :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.


×
×
  • Create New...