[RUBY] Rails web server and application server

Introduction

The command "rails s" that I used casually. With this command, I realized again what was working and how, so I will write it down.

** Supplement ** rails s is a command to start a local server.

table of contents

  1. Web server and application server
  2. Local environment
  3. Production environment

1. Web server and application server

In order to distribute the processing load (high-speed processing), the servers are divided by function.

** Web server ** Receive all requests from the client side. If the content of the request is static (HTML or CSS), the web server returns a response to the browser (client). If the content of the request is dynamic (searching for information from the database, etc.), pass the request to the application server.

** Application server ** Receives the request passed from the web server and performs the corresponding controller action. After that, the processing result is returned to the Web server.

2. Local environment

Type rails s in the terminal to launch the server. At that time, puma is displayed on the terminal. This is an application server for Rails and is not separated from the web server.

Terminal


=> Booting Puma
=> Rails 6.0.3.4 application starting in development 
=> Run `rails server --help` for more startup options
Puma starting in single mode...
* Version 3.12.6 (ruby 2.6.5-p114), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop

3. Production environment

In the production environment, the web server and application server are separated. As mentioned above, the reason is to take measures against server load such as concentrated access. Build a production environment by combining Nginx (Web server) and Unicorn (application server).

Reference page Why use Unicorn, Nginx in the production environment of rails? ~ About cooperation of Rack, Unicorn, Nginx ~ [Web service operation with Ruby On Rails]

that's all

Recommended Posts

Rails web server and application server
About rails application server
Comparison of WEB application development with Rails and Java Servlet + JSP
Rails and FormData
What is the difference between a web server and an application server?
Build Web Application Server (Java) on VPS
Try deploying Rails application to EC2-Part 2 (Server construction)-
Rails valid? And invalid?
Construction of authorization server using Authlete and communication from OAuth client (Web application)
Web application test automation
[Rails] Create an application
Rails server doesn't start.
Roughly the flow of web application development with Rails.
Create a JAVA WEB application and try OMC APM
Implement application function in Rails
Java (WebSphere Application Server) memo [1]
rails new application launch command
[Rails] N + 1 problems and countermeasures
Rails: Difference between resources and resources
Rails Posts and User Linkage
[Rails] require method and permit method
Rails "render method" and "redirect method"
Rails Tutorial Records and Memorandum # 0
I want to bring Tomcat to the server and start the application
rails path and url methods
[Spring Boot] Web application creation
Rails is difficult and painful!
Web application development article summary
Introducing Bootstrap and Font-Awesome (Rails)
Rails is difficult and painful! Ⅱ
How to terminate rails server
Web application built with docker (1)
[Rails] strftime this and that
How to run React and Rails on the same server
How to use Rails Current Attributes to track nginx (web server) and unicorn (app server) logs with X-Request-ID
Install Rails in the development environment and create a new application
[Rails] Save start time and end time
Preparing to create a Rails application
[Spring Boot] Precautions when developing a web application with Spring Boot and placing war on an independent Tomcat server
[Rails] Difference between find and find_by
Build a web application with Javalin
[Rails] Validation settings and Japanese localization
Rails model and table naming conventions
[Rails] I tried deleting the application
Chewing Rails Tutorial [Chapter 2 Toy Application]
Remove "assets" and "turbolinks" in "Rails6".
CRUD features and MVC in Rails
[Rails] Differences and usage of each_with_index and each.with_index
Project ruby and rails version upgrade
Connect to Rails server with iPhone
Web application creation with Nodejs with Docker
TCP: Basic Principles and Application Architecture
Application of downcase and slice methods
Consideration about Rails and Clean Architecture
About Docker, disguise server and container
[rails] Difference between redirect_to and render
Web application structure by Java and processing flow in the presentation layer
[Updated December 2018] Tips for embedded web server and servlet created with Jetty9
Spring Boot2 Web application development with Visual Studio Code SQL Server connection
Spring5 MVC web application development with Visual Studio Code SQL Server connection
Deploy the WEB application by Spring Boot to Tomcat server as WAR