enter image description here

Spoiler Alert: This article is not about Microservices architecture or how microservices works. In this article, I will share what we have learned in scaling one of the large SaaS platform, our ongoing improvements and how Microservices architecture is playing a key role in scaling this SaaS platform.

This SaaS Platform has experienced tremendous growth in the past 18 months. It has now become one of the leading CRMs in North America.

Everyone’s definition of “scale” and “growth” can differ...

Read complete blog post

Speed

  • Method Missing

Method Missing is one of the concepts of metaprogramming ruby. Although metaprogramming is very powerful it too has some shortcomings especially speed. A normal method is comparatively 1.5x times faster than a missing method. One of our users complained about our calendar page being very slow - on inspecting we found request was taking more than 30 seconds for loading the month view of the calendar and eventually request timed out. The user had lots of activities on that...

Read complete blog post

Almost all Ruby on Rails developers might come across scenario where they need to add a new column with a default value to one of the database tables. Most of us (including me) would write following migration statement -

add_column :table_name, :column_name, :boolean, default: false

This is a good practice but would cause downtime if the table has large number of records. It took 3 secs when I ran the migration for a table having 50k records.

-- add_column(:table_name, :column_name,...

Read complete blog post

Rails has provision to provide order of indexing on a column for better performance of like queries. The varchar_pattern_ops improves the performance of like queries by 4x.

For example, lets have this like query on name column (that has sequential index.)

Select * from users where name like 'John%'

We might have added a regular Rails index in migration for this name column as

add_index :users, :name - This will generate a sequential index.

The same can be made 4 times faster using btree index...

Read complete blog post

Lets say we need to benchmark and evaluate the performance of code snippet.

This is how we can easily do on Rails console using "Benchmark.ms"

1.9.3-p392 :001  Benchmark.ms do
1.9.3-p392 :002  "john mark McMillan".split(" ").collect{|word|word[0] = word[0].upcase; word}.join(" ")
1.9.3-p392 :003? end
 = 0.015000000000000001 
1.9.3-p392 :004  Benchmark.ms do
1.9.3-p392 :005  "john mark McMillan".gsub(/\b\w/) { |w| w.upcase }
1.9.3-p392 :006? end
 =...

Read complete blog post

In a Ruby On Rails applications where we follow convention over configuration, we might get hit by a slow server response, that would eventually cost users shy away from application.

There are many ways of how you can boost performance of Ruby On Rails applications. Focusing on approach depending on the application structure, size of the database and traffic intensity, our performance optimization can be carried out.

Rules for Performance Optimization
1) Measure
2) Optimize What is slow
3)...

Read complete blog post

Just found that I couldn't do zeus c test for a test environment console

Here's a workaround or small hack to do this

Steps

On your console do

 zeus init

This will create two files

 zeus.json
custom_plan.rb

Add this snippet to your custom_plan.rb and define the tasks for Zeus. Mine looks like this:

require 'zeus/rails'

class CustomPlan < Zeus::Rails
 def default_bundle_with_test_env
 ::Rails.env = 'test'
 ENV['RAILS_ENV'] = 'test'
 default_bundle
 end

 def test_server
 server
 end

 def test_console
 console
 end

 def test_rake
 prerake
 rake
 end
end

Edit zeus.json to include only the tasks for which you’ll use Zeus. Mine looks like this:

{
 "command": "ruby...
< Zeus::Rails def default_bundle_with_test_env ::Rails.env = 'test' ENV['RAILS_ENV'] = 'test' default_bundle end def test_server server end def test_console console end def test_rake prerake rake end end

Read complete blog post

The Bullet gem is designed to help you increase your application’s performance by reducing the number of queries it makes.

It will watch your queries while you develop your application and notify you when

a) when you should add eager loading (N+1 queries),

b) when you’re using eager loading that isn’t necessary and

c) when you should use counter cache.

Follow this link to read more - https://github.com/flyerhzm/bullet