Hi,
I am making a turn based multi-player game with some fixed rooms and some dynamic rooms. I also create, around 20 max, NPCs, which are created and disconnected dynamically in room extension. When I start the server the thread count is as low as 40 and within 17 - 18 hrs with the peak of 36 users it shoots up to 600+. [The active thread list shows a lot of threads named pool-n-thread-1] I do not know what is happening, I am quite new to java and smartfoxserver. Please help.
Thanks in advance.
Nandan
Thread Count keeps increasing
Re: Thread Count keeps increasing
Hi.
Are you using anything Timer related on your code? Please make sure that you use the TaskScheduler that comes with SFS2X (more information here).
And you might also consider using a global Task that iterates through every room instead of having one task for every room.
Are you using anything Timer related on your code? Please make sure that you use the TaskScheduler that comes with SFS2X (more information here).
And you might also consider using a global Task that iterates through every room instead of having one task for every room.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Re: Thread Count keeps increasing
Yes I am using TaskScheduler that comes with SFS2x at room level, that is restarted for each turn, is that a bad idea? How do I use global task, please help.
Re: Thread Count keeps increasing
Well, by a global Task I mean a task that runs at the Zone-Level, which has a local list of the rooms that will be iterated in each run.
If you're using this for a turn based, the best way would be to run the global task every second and reduce a time variable by 1 every run. Then, when that variable reaches 0, you execute the necessary code.
If you're using this for a turn based, the best way would be to run the global task every second and reduce a time variable by 1 every run. Then, when that variable reaches 0, you execute the necessary code.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Re: Thread Count keeps increasing
Got it . Thanks so much.
-
- Posts: 81
- Joined: 13 Sep 2011, 15:59
- Location: Nitra, Slovakia
- Contact:
Re: Thread Count keeps increasing
Hi rjgtav, I have around 500 rooms in Zone (those are game rooms with 2 users), by your mind I need one instance of scheduleAtFixedRate in that zone extension and this one scheduleAtFixedRate will be call every second and on each time this class will be update 500 room's variables ??? Every second changed 500 room's variables???
Re: Thread Count keeps increasing
Hi.
I forgot to mention that this "time" variabe is a hidden roomVariable, so it won't send any updates to any client. You can also use the room.getProperty() and room.setProperties() methods instead.
I forgot to mention that this "time" variabe is a hidden roomVariable, so it won't send any updates to any client. You can also use the room.getProperty() and room.setProperties() methods instead.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
-
- Posts: 81
- Joined: 13 Sep 2011, 15:59
- Location: Nitra, Slovakia
- Contact:
Re: Thread Count keeps increasing
Thank you rjgtav, plaese tell me about resizeThreadPool.
Is there some dependencies how to set resizeThreadPool ?
Branislav Belohorec
Is there some dependencies how to set resizeThreadPool ?
Branislav Belohorec
Re: Thread Count keeps increasing
Hi rjgtav,
I now have a global task that runs every second at zone level and I iterate through all my rooms (the list can increase to any limit in future) to execute a set of statements to update the game state. How do I ensure that every room is updated at the precise instance of time? Should I write some event listener at room level and zone extension should dispatch a message every second for room extension to handle states. Please help.
Regards
I now have a global task that runs every second at zone level and I iterate through all my rooms (the list can increase to any limit in future) to execute a set of statements to update the game state. How do I ensure that every room is updated at the precise instance of time? Should I write some event listener at room level and zone extension should dispatch a message every second for room extension to handle states. Please help.
Regards
Re: Thread Count keeps increasing
How do I ensure that every room is updated at the precise instance of time?
I don't fully understand your question.
The scheduler will fire an event every 1 second, so it will be precisely every second
Of course if the process of updating all rooms takes more than one second the next update will be handled by another thread (if the pool has more than one) and etc...
Of course it is unlikely that the process will take so long unless you are executing a very complex server side logic.
Re: Thread Count keeps increasing
Thanks so much Lapo for your reply, so you are saying that no matter how many rooms will I have in future, if I iterate through them and update their states it will all happen precisely within the same second without any delay. If it does take a little longer then I will have to resize the thread pool on fly, am I correct? And I assume the the number I must resize the thread pool to will again depend on the time my updates are taking.
Also, I got slightly confused after seeing this post viewtopic.php?t=10185, which says -
This was what I was doing previously when I got into the continuously increasing thread count problem. I now have just one global scheduler at zone level. Please tell me that whatever I am doing right now is better.
Thanks a ton!
Also, I got slightly confused after seeing this post viewtopic.php?t=10185, which says -
Use the master SmartFoxServer.getTaskScheduler with multiple runnables one per room.
This was what I was doing previously when I got into the continuously increasing thread count problem. I now have just one global scheduler at zone level. Please tell me that whatever I am doing right now is better.
Thanks a ton!
Re: Thread Count keeps increasing
Anyone, please reply.
-
- Posts: 81
- Joined: 13 Sep 2011, 15:59
- Location: Nitra, Slovakia
- Contact:
Re: Thread Count keeps increasing
My idea is using one scheduler on zone level, which will be iterate all rooms in zone every second. In this iteration it will be change room property (contain round seconds) decrement with number 1 and if the room property equal 0, scheduler update room variable (this variable detect end of game or round time is over) and it fire onRoomVariableUpade server event and onRoomVariableUpade function and here I use game logic like store data in DB , changing user variables (set new amout of score or whatever) . I think it can help to hold thread size.
Re: Thread Count keeps increasing
Don't update the DB every second, store the changes in the game for longer time and then, once in a while, you store those changes.
It could be too onerous to hit the DB every second and it will require a larger thread pool to keep up with the tasks. Instead you can use a separate task that runs every 2-3 minutes to update the DB
It could be too onerous to hit the DB every second and it will require a larger thread pool to keep up with the tasks. Instead you can use a separate task that runs every 2-3 minutes to update the DB
-
- Posts: 81
- Joined: 13 Sep 2011, 15:59
- Location: Nitra, Slovakia
- Contact:
Re: Thread Count keeps increasing
Thank you Lapo, is possible to write custom message into smarfox.log via extension ?
BB
BB
Who is online
Users browsing this forum: No registered users and 39 guests