Discussion:
RUDP, shared libraries, etc.
unknown
20 years ago
Permalink
Folks,

I'm writing client/server poker software and have a few questions
regarding Erlang...

Is there a reliable UDP implementation for Erlang? I would like my server
to support at least 10,000 simultaneous users and it seems that I could
only do 1024 with gen_tcp due to a Unix select limitation.

This seems like a non-issue with UDP but what's the best way to ensure
that messages are ordered and positively delivered? The documentation
states that messages sent from process A to B are indeed ordered but does
this apply to UDP?

I would like to build the user interface using the Torque Game Engine
(www.garagegames.com) and it uses a custom main on Windows and Mac OSX
which makes it very hard to build it into a shared library to be called
from Erlang. What is the best way to interface with Erlang here? Can I
make the Erlang runtime and my code into a shared library to be loaded
into C++?

P.S. I'm using Common Lisp right now

Thanks, Joel
--
http://wagerlabs.com/tech
unknown
20 years ago
Permalink
Erlang uses poll() instead of select() on platforms where it exists,
and it does not have the 1024 file descriptor limitation of select();
however, the OS itself may limit the number of allowed file descriptors.

You can use "ulimit -n" to change the number of allowed file
descriptors for a shell. On my Solaris 9 machine, I cannot exceed
1024 unless being root, but then it does not stop for at least
524288 (I did not try further). The same applies to Red Hat 9 Linux.

How efficient it is for half a Mega file descriptors I do not know...

UDP has its quirks that gen_udp reflects, e.g message ordering
is not guaranteed. It is not related to Erlang inter-process
communiation at all.

About Erlang as a shared library: the Erlang emulator (Beam)
also needs to be running main(). You might write interface code
in C to dynamically link with the game engine, and communicate
through an Erlang port program. I do not know, I hope someone
else will give a better answer on this point.
...
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
unknown
20 years ago
Permalink
Post by unknown
Is there a reliable UDP implementation for Erlang?
Not that I know of. Though I know people have played around with
implementing parts of TCP in Erlang (most recently: Luke Gorrie), but
I'd guess that none of that is intended/ready for serious use.
Post by unknown
I would like my server
to support at least 10,000 simultaneous users and it seems that I could
only do 1024 with gen_tcp due to a Unix select limitation.
A relatively conservative way around that limitation is to run
multiple Erlang VMs on the same machine. Erlang is intended for that
sort of design. A little bonus would be that your application would
then be ready to scale to multiple machines.
Post by unknown
This seems like a non-issue with UDP but what's the best way to ensure
that messages are ordered and positively delivered? The documentation
states that messages sent from process A to B are indeed ordered but does
this apply to UDP?
UDP makes few guarantees. A UDP message may be quietly lost in
transmission. A UDP message might arrive twice. UDP messages might
arrive out-of-order. This is a property of UDP, it's not
Erlang-specific.

If you run UDP packets over the big, bad internet, you'll see the above
happening, especially "quietly lost".

If you run UDP packets over a switched ethernet, you'll rarely, if
ever, see UDP misbehaving. UDP will seem reliable. YMMV.
Post by unknown
I would like to build the user interface using the Torque Game Engine
(www.garagegames.com) and it uses a custom main on Windows and Mac OSX
which makes it very hard to build it into a shared library to be called
from Erlang. What is the best way to interface with Erlang here?
See

http://www.erlang.se/doc/doc-5.0.1/doc/tutorial/part_frame.html

There are several ways to interface Erlang, each has advantages and
disadvantages. I'd suggest starting with something simple first,
e.g. running the two as seperate OS processes and communicating over a
TCP socket. Invent your own simple protocol.

If you want to make things more complicated, take a look at
erl_interface. But be warned: the mailing list is littered with the
corpses of beginners who have used erl_interface or linked-in drivers
without understanding them and then become completely baffled by the
resulting memory-corruption problems.
Post by unknown
Can I make the Erlang runtime and my code into a shared library
to be loaded into C++?
For practical purposes: no.

Matt
unknown
20 years ago
Permalink
Post by unknown
A relatively conservative way around that limitation is to run
multiple Erlang VMs on the same machine. Erlang is intended for that
sort of design. A little bonus would be that your application would
then be ready to scale to multiple machines.
Is there an idiom to implement this scalability in Erlang? That is how do
I run multiple instances of the VM on the same machine and have external
C code see them as one single server?

Thanks, Joel
--
http://wagerlabs.com/tech
unknown
20 years ago
Permalink
Post by unknown
Post by unknown
A relatively conservative way around that limitation is to run
multiple Erlang VMs on the same machine. Erlang is intended for that
sort of design. A little bonus would be that your application would
then be ready to scale to multiple machines.
Is there an idiom to implement this scalability in Erlang? That is how do
I run multiple instances of the VM on the same machine and have external
C code see them as one single server?
I was thinking "Erlang has nice support for writing distributed Erlang
programs, i.e. systems which run on multiple Erlang VMs which may or
may not be on the same machine. That may or may not be useful for your
particular problem." The Erlang Book has a whole chapter about this.

http://www.erlang.org/download/erlang-book-part1.pdf

I have a feeling that you were after a much more concrete answer. I
don't have one.

Matt

unknown
20 years ago
Permalink
You can increase your tcp limit using ulimit.

$> ulimit -n 11000

as root.

For some reason 'ulimit -n unlimited' did not work for me on Linux (SuSE).

tee

-------- Original Message --------
From: "Joel Reymont" <joelr1>
Apparently from: owner-erlang-questions
To: <erlang-questions>
Subject: RUDP, shared libraries, etc.
Date: Mon, 28 Mar 2005 21:27:55 +0100
...
unknown
20 years ago
Permalink
Post by unknown
I would like to build the user interface using the Torque Game Engine
(www.garagegames.com) and it uses a custom main on Windows and Mac OSX
which makes it very hard to build it into a shared library to be called
from Erlang. What is the best way to interface with Erlang here? Can I
make the Erlang runtime and my code into a shared library to be loaded
into C++?
It's always highly problematic to integrate two programs
that both require main() for filedescriptor polling.

Start off by keeping Erlang and Torque in separate processes
and invent some IPC mechansim between them.
TCP sockets over loopback is fast.


/klacke
--
Claes Wikstrom -- Caps lock is nowhere and
http://www.hyber.org -- everything is under control
unknown
20 years ago
Permalink
Post by unknown
Start off by keeping Erlang and Torque in separate processes
and invent some IPC mechansim between them.
TCP sockets over loopback is fast.
There's not my logic in my GUI as it simply does what the server tells
it. I think I'll just have the clients represented as ports in Erlang and
confine all Erlang to the server side.

I'm now looking for the idiom to implement load-balancing and scalability
so that a bunch of Erlang nodes look like one server to the clients. All
pointers are appreciated!

Thanks, Joel
--
http://wagerlabs.com/tech
Loading...