Smartfox Server Stopped Working

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
khokhani1510
Posts: 17
Joined: 06 Feb 2014, 11:08
Location: Gujarat, India
Contact:

Smartfox Server Stopped Working

Postby khokhani1510 » 11 Jul 2017, 04:53

Hello,


I am suffering from very crucial issue by Smartfoxserver,

I am using latest version of smartfoxserver and currently it's hosted under windows server.

When i am testing and developing with extensions it is working fine. At the interval of every 1-2 days server automatically stops working and need to restart it with command prompt. What might be the reason behind service/server stop ?

Help would be greatly appreciated.

Thank you
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox Server Stopped Working

Postby Lapo » 11 Jul 2017, 06:57

Hi,
the first place to look is in the log files (SFS2X/logs/smartfox.log)

Is it possible that the server is running short of memory or cpu? You should keep an eye on it via the AdminTool

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
khokhani1510
Posts: 17
Joined: 06 Feb 2014, 11:08
Location: Gujarat, India
Contact:

Re: Smartfox Server Stopped Working

Postby khokhani1510 » 13 Jul 2017, 06:18

I can not find any reasons in logfile, here is the attached log file after server has been stopped.
Attachments
smartfox.log.zip
(2.43 KiB) Downloaded 441 times
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox Server Stopped Working

Postby Lapo » 13 Jul 2017, 07:18

Thanks, the logs show less than 30 minutes of server activity... so there's not much I can investigate here.
You should have more log files in that folder. It would be interesting to see at least 1 cycle of activity, in other words from the boot up to the last restart.

Could you better describe what you mean by the "server stops"? Does it mean that the process auto shuts down? Or simply that the server is running but you can't connect? Even with the AdminTool?

If that's the case, are you using a database in your server side code?
If the answer is yes take a look at this -> http://smartfoxserver.com/blog/custom-l ... -database/
under the section "Handling Exceptions". It's a common issue.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
khokhani1510
Posts: 17
Joined: 06 Feb 2014, 11:08
Location: Gujarat, India
Contact:

Re: Smartfox Server Stopped Working

Postby khokhani1510 » 13 Jul 2017, 08:41

Thank you very much for your prompt support,

Here i attached more detailed log of smartfoxserver.


Server stops mean process got killed at hosting server. Server stops running and i need to restart service/server.
Attachments
Smartfox Log.zip
(97.08 KiB) Downloaded 435 times
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox Server Stopped Working

Postby Lapo » 13 Jul 2017, 08:49

Okay.
So if this happens, it is very likely that a monitoring app on your server instance is causing the problem. On many VPS/cloud instances they run a "process killer" that quits processes that use too much CPU / RAM or both.

Are you monitoring the resources on your machine?
What kind of hardware is it? What OS do you use?

Thanks
p.s. = the logs don't say much. I see there are lots of restarts, even within the same hour. Not sure if they were triggered manually or not.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
khokhani1510
Posts: 17
Joined: 06 Feb 2014, 11:08
Location: Gujarat, India
Contact:

Re: Smartfox Server Stopped Working

Postby khokhani1510 » 13 Jul 2017, 09:57

No there is no monitoring app on server.

Monitoring app: Not running
OS: Ubuntu 16.04 LTS
Hardware: 1 Cpu Core, 2 GB Ram, 30 GB SSD, 2 TB Transfer


I am using 5 taskSchedulers in different java class. Out of them 1 is running at fixed rate interval (per 1 second) for timer, 1 is running at interval at 10 seconds and rest are using for delayed function/method call.

2 schedulers - sfs.getTaskScheduler().schedule (......)
3 schedulers - sfs.getTaskScheduler().scheduleAtFixedRate (.....)

I am cancelling all these when calling destroy () function like this..

Code: Select all

    @Override
    public void destroy()
    {
        super.destroy();
       
        if(playerClockHandler != null)
        {
            playerClockHandler.cancel(true);
        };
    }



Is is possible that server process kill might be happening due to these schedulers ?

Here i attached server settings. Please check it. Rest settings in Server Configurator tab are default.
Attachments
Settings.zip
(167.73 KiB) Downloaded 444 times
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox Server Stopped Working

Postby Lapo » 13 Jul 2017, 13:48

khokhani1510 wrote:No there is no monitoring app on server.

Monitoring app: Not running
OS: Ubuntu 16.04 LTS
Hardware: 1 Cpu Core, 2 GB Ram, 30 GB SSD, 2 TB Transfer

Ok, but you can monitor via the SFS AdminTool or via top/htop directly on your machine.

There can only be two main reasons for this:
1) The server process quits because of a hard crash such as low level memory error.
2) The server is shut down by another "watchdog" process that checks for apps that take too many resources.

It would be helpful to understand which of the two is this. By monitoring your server during the day (especially peak hours) you should be able to see if the machine is running low on resources.

Let us know
p.s. = settings are fine
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
khokhani1510
Posts: 17
Joined: 06 Feb 2014, 11:08
Location: Gujarat, India
Contact:

Re: Smartfox Server Stopped Working

Postby khokhani1510 » 14 Jul 2017, 04:49

Please note the Thread Count is 43 now, which was continuously increasing before. Increasing 2-5 per two seconds and reached 1500 when i was observing (continuously increasing then after). But i have reduced Server task scheduler thread pool size to 4, before it was 1000. Is higher thread pool size might causing the problem ?

Yes definitely.
Thread are expensive on memory as thread must allocate memory for the stack.

I am not sure why you would need so many threads? Are your tasks blocking for a long time? If you're not making slow calls such as DB or external web services, keep the thread count of the scheduler to 2-3. That's enough to handle 1000s of tasks.

Cheers
Attachments
Screen Shot 2017-07-14 at 10.21.03 AM.png
(179.49 KiB) Not downloaded yet
User avatar
khokhani1510
Posts: 17
Joined: 06 Feb 2014, 11:08
Location: Gujarat, India
Contact:

Re: Smartfox Server Stopped Working

Postby khokhani1510 » 14 Jul 2017, 12:10

Okay, thanks.


Yes there are number of DB calls. But now let me wait and analyse server behaviour/performance with different use cases.

Thank you very much for your awesome support.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox Server Stopped Working

Postby Lapo » 14 Jul 2017, 14:20

Apologies, in my previous post I hit "Edit" instead of "Quote" and I accidentally edited your post instead of quoting it. :shock: :roll:

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 69 guests