    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Onward to American Online...</title>
        <link>https://members.accu.org/index.php/journals/741</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">CVu Journal Vol 10, #6 - Sep 1998 + Internet Topics</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c135/">106</a>
                    (12)
<br />

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c69/">Internet</a>
                    (35)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c135-69/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c135+69/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Onward to American Online...</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 03 September 1998 13:15:28 +01:00 or Thu, 03 September 1998 13:15:28 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="section" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a></h2>
</div>
<p>In last issue's article I talked about the evolution of the
multi-player game program Federation from its inception until we
got it running on General Electric's GEnie service. By the start of
1995 it was obvious that GEnie was on the way down. There were a
number of reasons for this. The division of GE that ran it - GE
Information Services (GEIS) - had never understood the service.
Bill Loudon, GEnie's founder had long since left, and it was
drifting about rudderless. GEIS had long been pulling money out of
GEnie to bolster its bottom line while refusing to invest in
updated equipment, condemning its customers to use 2400 modems
while everyone else had 9600. In addition, like most established
services it refused to acknowledge the importance of the nascent
Web.</p>
<p>Our contract with GE was not an exclusive one, and so for some
time we had been looking to run Federation on the other services.
It was about this time that we got a positive response from America
Online. At the time AOL was big, but nothing like the size it is
now. Its subscriber base was less than a million, and it was still
an hourly subscription service.</p>
<p>After discussion with AOL it was decided that we would port the
game to a Hewlett Packard Series 9000 RISC machine which AOL would
provide and host in their machine room. The interface to AOL would
be through a gateway originally designed for remote use. This
sounded just fine, and I came back to the UK with all the
documentation for Federation's programmer to study.</p>
<p>This gave us two things to do to get running on AOL - port the
code to HP-UX, and interface the program to AOL's gateway system.
The main thing we were worried about at this stage was porting to
HP-UX, which at that time had a reputation for being a somewhat
idiosyncratic flavour of Unix. In the event this proved not to be a
problem and the port itself went reasonably smoothly.
(Incidentally, over the last couple of releases HP-UX has moved
into the Unix mainstream.)</p>
<p>What did cause problems was the gateway interface. There were
number of contributory factors to this:</p>
<div class="orderedlist">
<ol type="1">
<li>
<p>The gateway had only been used internally by the group that
wrote it.</p>
</li>
<li>
<p>The documentation for the gateway was inadequate, and in places
incorrect.</p>
</li>
<li>
<p>The group handling the gateway appeared to have no line
management!</p>
</li>
</ol>
</div>
<p>All three of these things caused us problems both while we were
porting and on an ongoing basis. In particular, it meant that a
two-week trip to the US by Federation's programmer stretched to
over six weeks! By the time the first royalty cheque arrived we
literally had no money left in the bank!</p>
<p>Let's look at these problems one at a time...</p>
<p>First, the gateway code had only been used internally by the
group that wrote it. I suspect that the gateway project was
something that grew out of an internal project, rather than
something designed as an external interface from the start. The
routines used by the gateway group itself were very solid and very
robust, their everyday use had long since ironed out the bugs.
There were, however, a group of features that weren't used by the
gateway programmers, and these proved to be much flakier. I suspect
they were added as an afterthought when someone realised that the
interface could be used externally. In effect we were debugging
this code as we went along.</p>
<p>This is the perennial 'library' problem. A company writes a
library for internal use (3D graphics libraries are the most
obvious culprits) and finds it very useful. Then some bright spark
says 'Hey! We can sell this library and make back some of the money
it cost us to develop.' Then features are found to be missing so
they are added and the whole package goes onto the market as a
'revolutionary, full-featured xxx library'.</p>
<p>Unfortunately, the joins show. If you want to develop a library
for external use it needs to be specified as such right from the
start, all the features need to be properly tested, and the
interface needs to be complete. Take it from me - never buy a third
party library except from a vendor who only produces libraries.
This is one of the main reasons why PD/Shareware libraries are
often so full of promise but so disappointing when you come to use
them.</p>
<p>Second, the documentation was inadequate and/or incorrect. The
documentation was obviously meant to be of a proper standard - it
came in a loose-leaf folder with a couple of updates. I have no
doubt that it was fully documented from the point of view of the
gateway group - but the documentation was part of the body of their
work, E-mail, source code comments, group discussion etc.
Unfortunately all we had was the written specification, which
didn't incorporate this material.</p>
<p>This is another aspect of third party libraries - the
documentation must be comprehensive. (Oh and by the way -
programmers should be able to browse through documentation in the
bath, so trying to cut costs by providing electronic documentation
is a big no-no.) Documentation should come with a lot of simple
examples, each covering one, and only one, aspect of the library.
Nothing clever, nothing complex. I seem to remember that
Greenleaf's DOS comms library was a sheer delight from this point
of view.</p>
<p>Third, the group producing the gateway code didn't seem to have
a senior manager to whom they reported. They seemed to be
completely autonomous. This meant that there was no one we could go
to to iron out problems with the code. In practical terms we had to
write work arounds. In the event this wasn't such a problem at the
time of porting, because the other people we were dealing with at
AOL were highly competent and helped sort things out. Where it did
become a problem was later on.</p>
<p>We finally got up and running on AOL in mid-1995. It was magic -
we had more people than we had ever had playing the game. It soon
became obvious, though, that AOL users were a different breed to
those we had previously been used to. For the first time in its
history Federation needed a game management staff - what are now
called hosts and navigators - but that lies outside of the scope of
this article. It also became obvious that we needed to tweak the
game to cope with the increased number players (up from 10-20
players to 50-60).</p>
<p>It was while we were doing this that the first problems emerged
with the gateway to AOL. There was a general problem with the
gateway group making ongoing changes to their code and not telling
us, which meant that our code would mysteriously 'break'. Then
there was an ongoing project of theirs to port the gateway to
HP-UX. Since they swore there was 'no difference' they didn't give
us an opportunity to test their code with ours. One day they simply
put it in without telling us. Needless to say, our code stopped
working properly.</p>
<p>But the worst problem was changes in the interface specs. At one
stage they increased the maximum length of the messages that the
gateway sent us. Buffer overruns are incredibly difficult to spot!
Fortunately, we had a very good working relationship with the Games
Channel people who did everything in their power to smooth things
over. In late 1996 AOL announced that it was moving to a monthly
subscription, instead of hourly charges.</p>
<p>Sadly, they hadn't thought through the implications of this for
multi-player games, and failed to keep them charged on an hourly
basis.</p>
<p>The results were pretty obvious - everyone wanted to play the
games for hours on end. This caused both game design and coding
design problems for us.</p>
<p>The game design problems were easy to define, but more difficult
to correct. Federation was designed to be played in a pay per hour
environment. There was an underlying assumption that cost would
limit player's ability to stay on-line indefinitely. There were
also problems with the puzzles that required the use of what had
become, with several hundred simultaneous players, very scarce
objects indeed! The resolution of these problems is outside the
scope of this article.</p>
<p>Sorting out the coding design problems was more of an immediate
problem. At this stage we were running flat out with about 200
simultaneous players, and hordes more knocking at the door. We
approached AOL for a more powerful machine, but one was not
forthcoming. Not surprising really, since more players would
increase the load on their network without in-creasing their
revenue in any way. We were obviously going to have to solve this
at the software level.</p>
<p>At this stage a simplified view of what was happening looked
like this:</p>
<p>AOL-&gt;Gateway (AOL)-&gt;Gateway(Fed)-&gt;Fed driver-&gt;Fed
Server</p>
<p>Players came to us from AOL via the AOL part of the gateway.
This was the gateway code running on multiple machines that
multiplexed the users through to our machine. Our part of the
gateway, running on our machine, was one process for each of AOL's
machines. These processes de-multiplexed the input and passed it on
to the appropriate driver for the player. The driver in turn
communicated with the server. Remember that there was a driver for
each player and that all the links between processes were using
TCP/IP (the standard communications protocol for the Internet).</p>
<div class="sidebar">
<p class="title c2">A note on the concept of multiplexing.</p>
<p>Some of you may not have come across this concept before.
Basically <i class="firstterm">multiplexing</i> involves taking a
number of separate communication channels or streams and combining
them into a single channel. At the other end they are <i class=
"firstterm">de-multiplexed</i> from the single channel back into
the multiple channels. Multiplexing is a widely used technique
since it allows scarce communication resources to be used
efficiently.</p>
<p>Both hardware and software multiplexers exist. Hardware
multiplexers are faster and more efficient, but you can't reprogram
them as more efficient multiplexing algorithms are discovered.
Software multiplexers are slower, but programmable. You pays your
money and takes your choice.</p>
<p>Multiplexing is a vast subject, and I don't have time to go into
it here (or the specialist knowledge to do so). If you want to know
more then you need to consult your local reference library for
suitable texts.]</p>
</div>
<p>Now, TCP/IP is a very good protocol indeed when you are
communicating over services where packets might be delayed or lost.
But that robustness comes at a cost in processing, memory and time.
With (say) 200 players you would have 400 TCP/IP connections inside
the Fed host machine - 200 going into the drivers from the gateway,
and 200 from the drivers to the host. Now, none of these
connections was going out onto the network, so no packets were
going to be lost, clearly TCP/IP for the internal communications
was overkill, and we couldn't afford the cost. Various options were
looked at and we settled on UNIX pipes as a replacement. The result
of just a simple change was staggering - maximum usage shot up to
350 overnight.</p>
<p>Some of you might be wondering why we were using TCP/IP in the
first place. There were two reasons - portability and scalability.
TCP/IP was, when Fed was written, more readily available and at
that time most implementations of pipes went through a disk file.
Only relatively recently have pipes started to go through memory.
Our original ideas on scalability suggested that the way to scale
up the game to handle more players was to have the server on one
machine and the drivers on another machine. Using TCP/IP meant this
could be done with little or no re-coding.</p>
<p>But...</p>
<p>We still needed to get more players on to our host machine -
350, it was obvious, was still inadequate. Where to go next? Well,
we decided to look at the problems caused by having all these
different processes running on our host machine. In particular we
looked at context switching. Context switching is what the
processor does when it moves from one process to another. Before it
switches it has to save all the information about the old task (the
context) and load in all the information about the new task. This
takes time, lots of it.</p>
<p>To give you a feel for this problem let's scale down our 100Mhz
processor by 100 million to human time scales - 1 cycle a second.
The following table indicates the problem:</p>
<div class="table"><a name="d0e103" id="d0e103"></a>
<table summary=
"(Table information adapted from 'Practical Unix Programming' by K Robbins (0 13 443706 3), Prentice Hall @ &pound;36-99)"
border="1" cellspacing="0">
&lt;colgroup&gt;
&lt;col width=&quot;50%&quot;&gt;
&lt;col width=&quot;50%&quot;&gt;&lt;/colgroup&gt;
&lt;tbody&gt;
<tr>
<td>Processor Cycle time</td>
<td>1 seconds</td>
</tr>
<tr>
<td>Accessing the Cache</td>
<td>3 seconds</td>
</tr>
<tr>
<td>Accessing Memory</td>
<td>20 seconds</td>
</tr>
<tr>
<td>Context Switch</td>
<td>166 minutes</td>
</tr>
<tr>
<td>Disk Access</td>
<td>11 days</td>
</tr>
&lt;/tbody&gt;
</table>
<p class="title c2">Table 1. (Table information adapted from
'Practical Unix Programming' by K Robbins (0 13 443706 3), Prentice
Hall @ &pound;36-99)</p>
</div>
<p>As you can see context switching is expensive! The only way to
reduce the context switching was to run fewer processes.
Reluctantly, we decided to fold the driver processes into our end
of the gateway code. Why reluctantly? Because this would massively
hit the portability of the code by tying a significant part of the
Fed code into AOL's gateway code. None the less, we couldn't see
any option - we were caught in the oh so familiar portability v
efficiency dilemma. Nothing comes without a price, and the price of
portability is less efficient code. On the other hand we would also
halve the number of UNIX pipes we were using.</p>
<p>The results of this exercise were dramatic to say the least -
usage shot up to 800+ players with processor resources to spare! We
heaved a sigh of relief, and went on to start making game design
changes to cope with additional load.</p>
<p>It was at this stage that AOL decided that they didn't want
multi-player games any more...</p>
<p>But yet again I'm out of time and space, so the final part (I
hope) of this saga will have to wait for the next issue.</p>
<p>Have fun programming.</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
