Ruby on Rails 7.2, the latest version of the widely used web development framework, introduces several enhancements aimed at improving both performance and development workflow. Released on August 10, Rails 7.2 brings better production defaults and a more streamlined development container configuration, making it easier for developers to build and deploy efficient web applications. Proponents of the framework highlight the improved settings and new features as significant upgrades.
One of the key updates in Rails 7.2 is the adoption of better production defaults for optimized application performance. Notably, the YJIT (Yet Another Just-in-Time) compiler, a feature of Ruby 3.3 and newer, is now enabled by default. This can lead to faster application execution times, particularly for CPU-bound operations. Additionally, the number of default threads in the Puma web server has been reduced from five to three. This change reduces latency, as fewer threads mean less time spent waiting for the Global VM Lock (GVL) to release, thus improving concurrency and overall throughput.
Rails 7.2 also brings improvements to its Dockerfile generation, which now includes the jemalloc allocator by default. Jemalloc helps optimize memory allocation, contributing to better memory usage and faster performance, especially for applications that need to handle significant load. This makes it easier for developers to deploy Rails apps with better performance out of the box, without needing to manually adjust these settings.
For developers working in containerized environments, Rails 7.2 introduces a new feature for development containers. The framework can now automatically generate a .devcontainer configuration, which includes a Dockerfile, docker-compose.yml, and devcontainer.json files. These containers are preconfigured to support common databases like SQLite, Postgres, MySQL, and MariaDB, as well as a headless Chrome container for system testing. This new setup helps simplify the process of developing, testing, and debugging Rails applications in isolated environments, making the development cycle more efficient and consistent.