Ruby is a popular, open source programming language with a powerful and practical, yet natural and easy to read/write syntax. Ruby combines the best practices from various solutions to provide a unique object-oriented language, which aims for simplicity and provides such features as basic & special object-oriented features, operator overloading, exception handling, iterators and closures, garbage collection, and more.
Jelastic PaaS provides an out-of-the-box integration of Ruby web servers and management & automation tools (e.g., Ruby on Rails web-development framework) for comfortable Ruby cloud hosting and maximally convenient Ruby application development.
In this article, we’ll go through the distinctive features of Ruby Cloud Hosting and introduce the Ruby-related possibilities with Jelastic PaaS.
Ruby Environment Creation
Jelastic PaaS provides a powerful and intuitive topology wizard to set up the cloud hosting of new Ruby environments.
Switch to the Ruby language tab, select the required Ruby application server and Ruby engine version, add any other software stack as required. If needed, adjust other parameters, such as cloudlets (RAM and CPU), disk space, Public IPv4/IPv6, node count, etc.
Ruby Application Servers
Jelastic PaaS provides Ruby application servers based on Apache and NGINX software stacks. Both stacks are configured to utilize the Ruby on Rails framework for implementing web applications and the Passenger application server by default.
If needed, the NGINX Ruby stack can be easily configured to work with different builtin servers:
- Passenger – one of the most feature-rich application servers for Ruby, which are invaluable for the modern web apps and microservice API’s;
- Puma – a Ruby web server oriented on speed and parallelism due to fast and accurate HTTP 1.1 protocol parsing;
- Unicorn – an HTTP server, which takes advantage of the Unix/Unix-like kernels features for serving fast clients on low-latency, high-bandwidth connections.
The following Ruby versions are supported at the moment:
- Ruby 2.3.8;
- Ruby 2.4.6;
- Ruby 2.5.5;
- Ruby 2.6.3.
You can select the required version of Ruby via the topology wizard during the creation of a new environment, as well as adjust it for the existing instances via container redeployment.
Ruby Application Deployment
Jelastic PaaS automates the deployment process for the managed Apache Ruby and NGINX Ruby application servers using:
- Application archive uploaded from a local machine or via an external URL;
- Remote VCS repository (e.g., GitHub).
When deploying a Ruby application, only a single context (ROOT) can be used. However, you can select from three Deployment Types (i.e., RAILS_ENV) for it:
- development – reloads all application classes and turns off caching (allows a faster development cycle);
- test – wipes out database between test runs;
- production – turns on all caching.
If needed, you can switch between the Ruby deployment types via the appropriate drop-down list next to your application (see image below).
Read the related documents to learn more about the deployment of Ruby applications:
Ruby Dependency Management
All Ruby instances within Jelastic PaaS are provided with the Bundler dependency manager for automatic tracking and installing the exact gems and versions, which your project requires. If the project has a Gemfile in the root folder, it will automatically resolve dependencies with Bundler after deployment to the server without having to perform any manual intervention.
Also, if needed, you can include any Ruby framework into your Gemfile (Sinatra, Rack, therubyracer, Ramaze, etc.) or utilize Ruby on Rails – one of the most popular frameworks for developing and implementing web applications, which is available by default.
Refer to the Ruby Dependency Management documentation for additional information.
Ruby Post Deploy Configuration
In order to automate the repetitive actions that Ruby projects need to perform after an application is deployed (e.g., db:migrate), a rake_deploy file (located in the root folder of the project) can be created.
The file should contain a list of commands (each one from a new line) that will be executed consecutively via the rake tool after each restart of the Apache/NGINX node. After successful execution, the rake_deploy file is automatically removed. Refer to the Ruby Post Deploy Configuration documentation for additional information.
You can provide a custom domain name for your Ruby application to be used instead of the default one. Based on the environment topology, you should use:
- CNAME Record if using Shared Load Balancer; is recommended for development and test environments;
- DNS A Record if using Public IP; can handle high traffic load and is suitable for production environments.
To switch traffic from one environment to another environment (e.g., to redirect customers to the newer application version without downtime), the swap domains functionality should be used. It is also available as the SwapExtIps API / CLI method.
Automatic Vertical Scaling
One of the key-features of Jelastic PaaS is dynamic provisioning of the exact amount of resources (RAM and CPU) required by your nodes according to the current load with no manual intervention. Just set the required cloudlets limit (128 MB of RAM and 400 MHz of CPU each) for your Ruby application server and everything else will be handled by the platform automatically.
As a result, you automatically benefit on a truly user-oriented pay per use charging approach and don’t need to guess or predict the incoming load. It ensures that you never overpay for unused resources and saves your time because the platform eliminates the need to handle the load-related adjustments or perform architectural changes manually.
Refer to the Automatic Vertical Scaling documentation for additional information.
Manual Horizontal Scaling
Horizontal scaling via Jelastic PaaS is as simple as selecting the required number of nodes via the corresponding section in the topology wizard. Additionally, you can choose between two scaling modes:
- Stateless – simultaneously creates all new nodes from the base image template;
- Stateful – sequentially copies file system of the master container into the new nodes.
The maximum number of the same-type servers within a single environment layer depends on default platform settings (usually this limit stands for 16 nodes and can be enlarged by sending the appropriate request to support).
Automatic Horizontal Scaling
You can configure automatic horizontal scaling for your Ruby environment through tunable triggers, which monitor the changes in the nodes load and increase/decrease their number appropriately.
The process is simple, access environment Settings > Monitoring > Auto Horizontal Scaling section, choose the required layer and resource to be monitored (CPU, RAM, Network, Disk I/O, Disk IOPS). Set the exact condition of scaling via the intuitive UI form.
In addition, cloud hosting at Jelastic PaaS allows using other built-in tools and features, for example:
- Built-in or Custom SSL;
- Public IPv4 and IPv6;
- A wide range of complementary software stacks, including SQL and NoSQL databases;
- Container firewalls, endpoints and environment network isolation;
- User-friendly UI and SSH access;
- Open API and Cloud Scripting for automation;
- Pay as you use pricing model;
- Collaboration for teamwork;
- Multi-cloud distribution.
Get your free trial account and start exploring Ruby cloud hosting benefits at our Jelastic PaaS platform for your own applications!