Thousands of NPC

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

juancarlos
Posts: 69
Joined: 21 Dec 2007, 17:19
Contact:

Thousands of NPC

Postby juancarlos » 23 Jun 2009, 08:00

Hello.

I have read that:
KNOWN PROBLEMS:
There is a known bug related to the creation of non-player characters (NPC). We have noticed that all connections coming from NPCs remain in CLOSE_WAIT state after closing them. This is not an issue if NPCs are created once and then used for the entire life cycle of the server instance. However if you plan to dynamically create and destroy many of them it could eventually exhaust the number of sockets/file-descriptors available of the underlying OS.


I would like to create and destroy more or less 20 users per hour, which is over 500 NPC per day. According to the comment quoted, which comes from documentation, this could give me problem.

My questions are:
1- Is it so? I mean: If I create and destroy 500 or 1000 users per day, will I have problems with my server?
2- Is it planned to fix that issue? If so, when is it expected to be fixed?

Thank you again.
Fun Bobby
Posts: 48
Joined: 26 Sep 2008, 11:23

Postby Fun Bobby » 23 Jun 2009, 10:51

hi,

1- Is it so? I mean: If I create and destroy 500 or 1000 users per day, will I have problems with my server?


yes at the moment the server gets very slow after a while. You cannot handle NPCs this way at the moment.

We found a better way for use handling over 1000 NPCs an hour. We move the unused NPCs to a NPC-Room and keep them connected to the server. When we need new NPCs we take them from the NPC-Room.

But after all it would be nice to have the option to clean up the NPC-Room and disconnect the NPCs sometime.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 25 Jun 2009, 05:59

To avoid the known bug, you can write an external application (better in Java using the SFS Java API) that simulates any number of NPCs which can be created and destroyed without problems.

As regards the fixing of this problem we have no estimated date as it depends on a specific TCP issue, and is not much related with our code.

Also we're working on the next major release which will introduce connection-less NPCs, eliminating the problem from the root.
Lapo
--
gotoAndPlay()
...addicted to flash games
duke
Posts: 31
Joined: 16 Apr 2009, 11:23

Postby duke » 11 Jul 2009, 06:59

Lapo wrote:To avoid the known bug, you can write an external application (better in Java using the SFS Java API) that simulates any number of NPCs which can be created and destroyed without problems.

As regards the fixing of this problem we have no estimated date as it depends on a specific TCP issue, and is not much related with our code.

Also we're working on the next major release which will introduce connection-less NPCs, eliminating the problem from the root.


That sounds great Lapo! I was thinking this over last night and how i'd pretty quickly run over the 20 user limit when testing npc's! But it seems you're already working on a solution!
markstudio
Posts: 19
Joined: 22 Apr 2009, 00:13
Contact:

Postby markstudio » 20 Nov 2009, 03:05

i am having the same problem, i run tournaments every hour on the hour GMT time, i create about 50 NPCs per tournament and destroy them after the tournament is over ... but i noticed they still occupy the memory even after disconnection, it eats up all resources within 24 hours of the server running, the only solution i found is to restart the smartfox server every day between tournaments.

Lapo how far are you from releasing the next major release? Specifically connection-less NPCs feature?
markstudio
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 20 Nov 2009, 05:46

Yes, this problem is listed in the known issues in our release notes.
We don't recommend using the createNPC() functionality if you plan to dynamically create and destroy NPCs. What you can do is separate the NPC logic from the server creating another Java application that uses the SFS API to create multiple NPCs.
This way you will not have problems shutting down connections.

Lapo how far are you from releasing the next major release? Specifically connection-less NPCs feature?

The next major release involves a new architecture, lots of code rewriting, tons of new features and a vastly improved framework. At the moment I am not able to disclose any release dates. We'll provide more details as they will become available.
Lapo

--

gotoAndPlay()

...addicted to flash games
cyli
Posts: 16
Joined: 09 Mar 2010, 18:39

Postby cyli » 22 May 2010, 01:05

Hi there - I am also running into this problem, but I don't quite understand what you mean by:

"We don't recommend using the createNPC() functionality if you plan to dynamically create and destroy NPCs. What you can do is separate the NPC logic from the server creating another Java application that uses the SFS API to create multiple NPCs.
This way you will not have problems shutting down connections. "

Do you mean not create new User objects at all? Could you elaborate a bit on this solution?

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

Postby Lapo » 22 May 2010, 05:48

No. We simply warn developers that if you plan to continuously create and destroy NPC Users you might end up with the described problem. The issue might appear when running thousands of NPCs.

SmartFoxServer 2X will solve this issue as its new engine provides socket-less NPCs. http://www.smartfoxserver.com/2X/
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 22 guests