![]() ![]() ![]() # Lets say you have some categories you offer in your project. Here is an example of how easy it is to do a cache with an expiry time: Rails makes this incredibly easy to do right out of the box. Sometimes if you have a lot of static data or you can’t make things faster, another alternative is to use a cache. This gem is a whopping 25 times faster than the default ActiveModelSerializers and I can personally vouch for that from experience. I would strongly suggest switching over to the fast_jsonapi by Netflix. If you have an API in your project you are most likely using the ActiveModelSerializers gem for serializing your data. The good thing for us is that Rails has multiple options to achieve this easily - Sidekiq, Rescue or ActiveJob. Minimizing work in the main thread will ensure a snappy response for users. Whenever you need to do anything complicated or long-running, consider throwing it into a background worker - sending an email, push notifications, uploading pictures and the like. ![]() Be careful while selecting what gems to add to your project and try keeping your dependencies lean. But it’s easy to get carried away adding gems to your project, causing bloat. Rails is backed by an amazing community behind it and a library of gems that can easily help you accomplish complicated tasks. You won’t accomplish much by shaving off milliseconds in serialization if your database queries are extremely slow. The idea behind this is to not waste time on micro-optimizations while you have bigger issues that need resolution. It’s also known as the ‘law of vital few’ and states that for most events, 80% of the effects are generated from 20% of causes. This is a well-known rule when it comes to developing software - The Pareto Principle. This will help you skip the pain of jumping multiple versions and ensures that you have all the newer performance enhancements. So do yourself a favor and try to keep in sync with the newer versions of Ruby and Rails. I know personally how horrifying updating the Rails version for your project can be if you left it stale for too long, and I sympathize with anyone who had to go through this ordeal. A more affordable alternative is SkyLight’s free trial. Personally, I’ve found New Relic to be one of the best APM tools for Rails but it is a tad bit on the pricey side. You should be tracking load times, request times, and database query timings amongst other things. You can’t improve performance if you don’t measure it first, making it necessary to have the right metrics tracked and monitored. This article aims to list the most important tips & tricks I’ve learned over the years to make Rails run at blazing fast speeds and scale to millions of requests per minute.įirst off, there are some general tips to implement in your Rails project to set yourself up for success. So before you jump ship, you should consider keeping performance at the forefront of your mind when working with Rails, and you can succeed too. Despite this, there are many companies out there who have succeeded in scaling Rails and found success - just take a look at Airbnb, Github, Gitlab & Shopify. You will find examples of individuals and companies drifting away from Rails in favor of something else. ![]() However, it’s not considered the fastest framework out there in terms of performance. It’s useful right out of the box and comes with a plethora of behind-the-scenes magic to make your life easier. Ruby on Rails is a tremendous framework when you want development speed for your project or startup. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |