<!-- MHonArc v2.4.4 --> <!--X-Subject: Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ?? --> <!--X-From-R13: Hnqvz Fxnpuraxb <igNserrubyq.pebpbqvyr.bet> --> <!--X-Date: Wed, 25 Mar 1998 05:23:38 +0000 --> <!--X-Message-Id: 35185D49.6E6B1B72#freehold,crocodile.org --> <!--X-Content-Type: text/plain --> <!--X-Reference: Pine.PMDF.3.95.980323144315.543526539A-100000#nova,wright.edu --> <!--X-Head-End--> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>MUD-Dev message, Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</title> <!-- meta name="robots" content="noindex,nofollow" --> <link rev="made" href="mailto:vt#freehold,crocodile.org"> </head> <body background="/backgrounds/paperback.gif" bgcolor="#ffffff" text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000"> <font size="+4" color="#804040"> <strong><em>MUD-Dev<br>mailing list archive</em></strong> </font> <br> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] <br clear=all><hr> <!--X-Body-Begin--> <!--X-User-Header--> <!--X-User-Header-End--> <!--X-TopPNI--> Date: [ <a href="msg00883.html">Previous</a> | <a href="msg00885.html">Next</a> ] Thread: [ <a href="msg00852.html">Previous</a> | <a href="msg00885.html">Next</a> ] Index: [ <A HREF="author.html#00884">Author</A> | <A HREF="#00884">Date</A> | <A HREF="thread.html#00884">Thread</A> ] <!--X-TopPNI-End--> <!--X-MsgBody--> <!--X-Subject-Header-Begin--> <H1>Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</H1> <HR> <!--X-Subject-Header-End--> <!--X-Head-of-Message--> <UL> <LI><em>To</em>: <A HREF="mailto:mud-dev#null,net">mud-dev#null,net</A></LI> <LI><em>Subject</em>: Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</LI> <LI><em>From</em>: Vadim Tkachenko <<A HREF="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</A>></LI> <LI><em>Date</em>: Tue, 24 Mar 1998 19:26:33 -0600</LI> <LI><em>Sender</em>: <A HREF="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</A></LI> </UL> <!--X-Head-of-Message-End--> <!--X-Head-Body-Sep-Begin--> <HR> <!--X-Head-Body-Sep-End--> <!--X-Body-of-Message--> <PRE> s001gmu#nova,wright.edu wrote: > > On Sun, 22 Mar 1998, Matt Chatterley wrote: > > > On Sun, 22 Mar 1998, Chris Gray wrote: > > > [Ben Greear:] > > > > [Snip] > > > > > :Also, as a java server, I don't think I can do a select on incomming > > > :data. I think a thread for every player is a bit much...any suggestions > > > :here? > > > > > > I have just started into the socket programming stuff of the current Java > > > book I'm reading, but I just went and did some scanning. The technique > > > he suggests for a server is to create some fixed number of threads, and > > > re-use those threads throughout the lifetime of the server. He says that > > > some Java implementations do not garbage collect threads at all, so having > > > one per connection can result in an eventual crash due to lack of memory. > > > Ick. Given the lack of a 'select' or 'poll' method in Java, the choices > > > are quite limited. Double ick. > > [...] > > > Reusing threads is probably desirable, by the way, especially if less work > > will be done to re-use an existant thread than to create a new one, and > > not hard to do. > > As I understand it, it is usualy a LOT less work to reuse a thread that to > destroy/create a new one. > > > Consider a model where you have a resizeable array (see the Vector class) > > of Threads. You also maintain a list of available threads so you do not > > have to recalulate it, and follow a procedure akin to: > > > > New connection is made to the server: > > Check list of available threads. > > If null: extend the Vector and add a new thread to handle the > > connection. > > If not null: take the 'top' thread and re-assign it. > > > > A connection closes: > > Add that thread to the list of available threads. > > Suspend and 'reset' the thread. > > > > Seems interesting anyway. :) > > This is very similar to a discussion we had about multi-threading event > drivers. You might also consider, to reduce the number of creates and/or > unused threads at the end of your array, a pool approach, with a min/max > available setting. Something like so: > > You create the pool (array, call it what you will), with min/max avail set > to 2/5. It starts with 5 avail (all unused). One person connects. no > problem. Then 3 more connect. Now we have 4 in use, 1 avail, so the pool > adds a new thread, taking the total count up to 6, 4 in use, 2 avail. > lets say everyone then logs out. The pool has 6 avail, so it deletes > one, to maintain the max avail at 5. This scheme works well, as long as > you don't change the number of threads in use too radically. Constant, > radical changes in number will prolly just add overhead to a simpler > scheme, but as long as it fluctuates within the range you specify, it > shan't create or destroy any threads. > > I liked the model, but haven't adopted it for my event driver. I want to > run some tests with a static pool first, and see if I really do need a > dynamic pool. Once again, for those interested there is the implementation of two pairs: Packet/PacketSwitcher Channel/ChannelSwitcher. Implement the minSpare/maxSpare concept, with the addition: maxRunning - I run into it when I needed to support the evaluation copy with a limit of 2 concurrent connections :-)) Packet and Channel are the resources to share, just as an example - database connection with autocommit is a Packet, database connection which you need to commit/rollback manually is a Channel. Switcher, respectively, is an object which maintains the proper number of available resources in according to guidelines. > -Greg -- Still alive and smile stays on, Vadim Tkachenko <vt#freehold,crocodile.org> -- UNIX _is_ user friendly, he's just very picky about who his friends are </PRE> <!--X-Body-of-Message-End--> <!--X-MsgBody-End--> <!--X-Follow-Ups--> <HR> <!--X-Follow-Ups-End--> <!--X-References--> <UL><LI><STRONG>References</STRONG>: <UL> <LI><STRONG><A NAME="00852" HREF="msg00852.html">World Persistence, flat files v/s DB v/s ??</A></STRONG> <UL><LI><EM>From:</EM> s001gmu#nova,wright.edu</LI></UL></LI> </UL></LI></UL> <!--X-References-End--> <!--X-BotPNI--> <UL> <LI>Prev by Date: <STRONG><A HREF="msg00883.html">Re: [MUD-Dev] Describe Concept</A></STRONG> </LI> <LI>Next by Date: <STRONG><A HREF="msg00885.html">Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</A></STRONG> </LI> <LI>Prev by thread: <STRONG><A HREF="msg00852.html">World Persistence, flat files v/s DB v/s ??</A></STRONG> </LI> <LI>Next by thread: <STRONG><A HREF="msg00885.html">Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</A></STRONG> </LI> <LI>Index(es): <UL> <LI><A HREF="index.html#00884"><STRONG>Date</STRONG></A></LI> <LI><A HREF="thread.html#00884"><STRONG>Thread</STRONG></A></LI> </UL> </LI> </UL> <!--X-BotPNI-End--> <!--X-User-Footer--> <!--X-User-Footer-End--> <ul><li>Thread context: <BLOCKQUOTE><UL> <LI><strong><A NAME="00819" HREF="msg00819.html">Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</A></strong>, Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 22 Mar 1998, 18:21 GMT <UL> <LI><strong><A NAME="00822" HREF="msg00822.html">Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</A></strong>, Greg Munt <a href="mailto:greg#uni-corn,demon.co.uk">greg#uni-corn,demon.co.uk</a>, Sun 22 Mar 1998, 19:02 GMT </LI> <LI><strong><A NAME="00823" HREF="msg00823.html">Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</A></strong>, Matt Chatterley <a href="mailto:matt#mpc,dyn.ml.org">matt#mpc,dyn.ml.org</a>, Sun 22 Mar 1998, 19:19 GMT <UL> <LI><strong><A NAME="00852" HREF="msg00852.html">World Persistence, flat files v/s DB v/s ??</A></strong>, s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Mon 23 Mar 1998, 19:51 GMT <UL> <LI><strong><A NAME="00884" HREF="msg00884.html">Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</A></strong>, Vadim Tkachenko <a href="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</a>, Wed 25 Mar 1998, 05:23 GMT </LI> </UL> </LI> <LI><strong><A NAME="00885" HREF="msg00885.html">Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</A></strong>, Vadim Tkachenko <a href="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</a>, Wed 25 Mar 1998, 05:26 GMT <UL> <LI><strong><A NAME="00894" HREF="msg00894.html">Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</A></strong>, Matt Chatterley <a href="mailto:matt#mpc,dyn.ml.org">matt#mpc,dyn.ml.org</a>, Wed 25 Mar 1998, 08:47 GMT <UL> <LI><strong><A NAME="00899" HREF="msg00899.html">Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</A></strong>, Vadim Tkachenko <a href="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</a>, Thu 26 Mar 1998, 01:59 GMT <UL> <LI><strong><A NAME="00904" HREF="msg00904.html">Re: [MUD-Dev] World Persistence, flat files v/s DB v/s ??</A></strong>, Joel Dillon <a href="mailto:emily#cornholio,new.ox.ac.uk">emily#cornholio,new.ox.ac.uk</a>, Thu 26 Mar 1998, 15:52 GMT </LI> </UL> </LI> </UL> </LI> </UL> </LI> </UL> </LI> </UL> </LI> </UL></BLOCKQUOTE> </ul> <hr> <center> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] </center> <hr> </body> </html>