of the controller stack • Your Rails app is probably already thread-safe • If not, it’s very, very bad request a thread 1 request b thread 2 request c thread 3
new_format end # etc. end def file_for_paperclip(filename, content, content_type) file = StringIO.new(content) metaclass = class << file; self; end metaclass.class_eval do define_method(:original_filename) { filename } define_method(:content_type) { content_type } end file end
... end # This method is not thread-safe. def silence_stream(stream) # ... end • Some code in Rails is not thread-safe • Search all your gems: > ack "\.quietly" `bundle show --paths`
your local Maytag(tm) repair man. lowlevel_error_handler do [302, {'Content-Type' => 'text', 'Location' => 'http:// jobber.s3.amazonaws.com/error_pages/error.html'}, ['302 found']] end puma.rb
the Dynos • less Dynos reduces cost and queuing • memory headroom (1GB) • we can visualize & track down memory bloat • not constantly restarting processes