Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Stateful Application Server in JRuby

Stateful Application Server in JRuby

The talk includes an introduction to the problems that were solved by choosing a stateful applicaton server.

I will explain constraints, benefits and obvious differences to traditional database backed application servers.

Images taken from http://www.flickr.com/photos/x-ray_delta_one <3

Recording: http://media.eurucamp.org/#talk-2013-Overbryd

Lukas Rieder

August 15, 2013
Tweet

More Decks by Lukas Rieder

Other Decks in Technology

Transcript

  1. class Session attr_reader :lock def initialize @lock = Mutex.new end

    # ... end session.lock.synchronize do session.foo end
  2. class SessionManager @current = ConcurrentHashMap.new def self.get(id) raise WrongShard unless

    Shard.valid?(id) unless session = @current.get(id) new_session = create(id) unless session = @current.put_if_absent(id, new_session) session = new_session end end session end end
  3. t1 t2 {} S S session = @current.get(id) # =>

    nil session = @current.get(id) # => nil
  4. S2 new_session = create(id) unless session = @current.put_if_absent(id, new_session) #

    => nil session = new_session # => #<Session:0x2> end t1 new_session = create(id) unless session = @current.put_if_absent(id, new_session) # => #<Session:0x2> t2 {} S S S1 S2 S2 S2
  5. class Broadcast def self.spawn_listener Thread.new do socket = wait_until_socket_bind loop

    do if @stop_listener socket.close return end message, from = socket.recvfrom(1024) handle_message(message) end end end end