Foreground of green rolling hills with wind turbines in the background.
Photo by Appolinary Kalashnikova on Unsplash.

As a digital preservation service, APTrust is committed to preserving not only our members’ data but also the environment. A few years ago, we decided to rewrite our core application, Pharos, in Go, a fast and efficient programming language. Ruby on Rails was constraining our ability to meet members’ needs, but we also knew Go used fewer compute resources than Ruby or Ruby on Rails.

Pharos was the web interface that allowed our members to access, manage, and monitor their preserved data. It was originally written in Ruby on Rails, a popular web framework that offers many features and conveniences, but also comes with a high cost in terms of performance and resource consumption.

We knew that Ruby on Rails was slow and memory intensive, but we were shocked to learn just how much electricity it was using compared to Go. According to a recent article by The New Stack, pure Ruby uses about 30 times the electricity of Go, based on CPU usage, memory usage, and execution time1. Ruby on Rails would use even more, due to its heavy use of runtime evaluation and complex object structures.

We decided to rewrite Pharos in Go, a language that is designed for speed and simplicity, and that has a built-in concurrency model that makes it easy to handle multiple requests efficiently. We named the new application Registry, and we were amazed by the results.

On our initial performance tests, Registry was about 16 times more CPU efficient and 300 times more memory efficient than Pharos. It also responded much faster to user requests, reducing the wait time and improving the user experience. Most importantly, it reduced our energy consumption significantly, saving both money and the environment. Pharos used 8 CPUs and 16 GB of RAM while Registry uses only 0.5 CPU and 50 MB of RAM with better performance.

We are very happy with our decision to switch from Ruby on Rails to Go, and we encourage other web developers to consider the environmental impact of their programming choices. By choosing a more efficient language, you can not only improve your application’s performance but also contribute to a more sustainable future.

Note: This blog post was drafted by Microsoft Co-Pilot based on notes from Andrew Diamond with editing by Nathan Tallman.