kevsmith / gemini

Demonstrating message fanout via sockets

This URL has Read+Write access

gemini /
name age message
file Makefile Loading commit data...
file README.markdown
directory src/
README.markdown

Description

Demonstration of quasi-efficient message broadcast using Erlang's concurrency over TCP/IP sockets.

This code was inspired by Joel Reymont's bounty to optimize his message delivery server (see here for more details). This server does less than Joel's but has demonstrably better performance, at least as Joel has measured it. There are some differences in Joel's technique and mine in that he also measures set up time while I only measure the time it takes to deliver the broadcast message to all clients.

Note: I was seeing total delivery times in the 48 - 50 millisecond range for 5K clients. I stopped benchmarking after that due to lack of access to suitable hardware.

Take from this code what you will. I hope it helps shed some light on writing networked servers in Erlang for someone.

--Kevin

Instructions

  1. run make

  2. In one terminal window run the server: erl +K true -pz gemini/ebin -s gemini

  3. In one or more additional terminals, start the client shells: erl +K true -pz gemini/ebin

  4. In each client shell, initialize the clients:

    C = gemini_stress:init(8081, 1000).
    

  5. Pick one shell to initiate the broadcast. In that shell run:

    gemini_stress:send(C).
    

  6. The total time to send the message to all connected clients (in milliseconds) will display in the server window.