Further Questions

I’m finally sitting down and trying to look into the questions that built up from the past week

  • Why adding the ruby gem foreman into the Gemfile is not recommended?

    This ruby gem is used for organizing apps with multiple components and uses a Procfile. The Procfile lists which processes foreman is suppose to manage. Heroku has an article that provides further details on Procfiles and the github page for foreman also has an extensive manual. What jumped out the most from the foreman manual were the flags for port and concurrency which managed how many workers would be used for each process. From the heroku article , the most basic command in the Procfile was bundle exec rails server -p $PORT but more processes can be added. From what I can find, Heroku didn’t suggest adding foreman into the Gemfile because its already added by default.

  • How does Unicorn interact with Rack Applications ?

    I found an article that clarified the features that Unicorn has. There was also another article on how they can be configured at Digitial Ocean. Both articles wrote about the advantages of using Unicorn but I didn’t start seeing how it could be implemented until I looked at the guide for the Rails Initialization Process. At the end of the guide, it mentioned that the process would be handed off to the specific server implementaion and that led me to the Unicorn::HttpServer class. I’m not sure how the process goes after it reaches this point, but I’ll read the source code more in detail to find out. I do know from the comments that a server could be run using HttpServer::run. In the future, I want to write a blog post that extends the guide to how Unicorn would handle the last line server.run wrapped_app, options, &blk.

  • What are the major differences between Unicorn, Thin , Puma and other Rack web servers ?

    This article was a great start on figuring out the differences between the servers. The answer produced even more questions though. Specifically on what is NGINX, Mongrel’s parser, Event Machine network I/O library, and the specifics of Rack middleware for HTTP requests.

  • How does concurrency and thread-safe work in a Rails?

    I started looking at stackoverflow to find out what concurrency and thread-safe means. There was also another post on what isn’t thread safe in Ruby. Rails has a specific configuration that is turned on by default and this post went into through an indepth discussion about what that configuration did. The most interesting parts was when he said that “We know that loading the framework isn’t threadsafe, so the strategy is to load it all up before any threads are ready to handle requests” and that the @allow_concurrency option turns off a Rack Middleware called Rack::Lock. Again, this opened up more questions about the difference between multi-threaded servers and multi-process servers along with the difference between eager loading and lazy loading.

      def threadsafe!
          @preload_frameworks = true
          @cache_classes      = true
          @dependency_loading = false
          @allow_concurrency  = true
          self
      end
    
  • How to configure a deployment through environment variables?

    After finding two articles about it from railsapps and tealeaf, the best ways I read to manage environment variables centers around two gems; figaro and dotenv-development. Both use a separate file, .env and application.yml respectively, that can be used to set environment variables and should not added to the public repository.

  • What are the best practices for deploying a Rails application?

    There were many articles about this and I found that the best practices revolve around where you’re deploying to and the specific requirements for your app. A common thread I found was using a tool to standardize the process like capistrano, chef, or puppet.

Even more questions

  • What is NGINX?
  • What is Mongrel’s parser?
  • What is Event Machine network I/O library and how does it work?
  • How does Rack middleware and Rack in general work with Ruby web applications?
  • What is the difference between multi-threaded servers and multi-process servers?
  • What is the difference between eager loading and lazy loading?
  • How could I use capistrano, chef or puppet ?