Recent Posts

I was using a Amazon Elasticache cache.t2.medium Redis instance as a cache store for one of the Rails application. Over the time I observed that connections to Redis instance are increasing day by day and once it hit ~1500, the Rails application started throwing connection timeout exceptions:

1
Error connecting to Redis on redis-host:6379 (Redis::TimeoutError)

On searching over internet, I found that the default parameter group has timeout value set to 0 which means, any connection that has been initialized to redis will be kept by redis even if the connection initialized by the client is down. Well the first thing I did was to create a new parameter group and set its value to a non-zero integer. However I couldn’t apply the parameter group changes to live production application and hence started looking for alternatives.

Continue Reading »

If you need to send transactional emails from your Rails application, you should always send them asynchronously using a background job. If you send transactional emails synchronously, the user will see a loading page for the time rails connect to SMTP server and delivers your email which is about 2-3 seconds. This will result in a very bad user experience and it’s advisable to send emails using a background job.

Sidekiq advertises it self as simple, efficient background processing engine for Ruby. Sidekiq has dependency on Redis version 2.4 or greater. Hence to setup Sidekiq on OpenShift, we have to setup Redis first. So let’s get started.

Setting up Redis

Redis cartridge for Openshift is available here. To add this cartridge to existing Openshift application, issue following command:

1
rhc add-cartridge http://cartreflect-claytondev.rhcloud.com/reflect?github=smarterclayton/openshift-redis-cart
Continue Reading »

Active Admin is an administration framework for Ruby on Rails applications which helps in creating beautiful administration panels. Paperclip is a file attachment library for Active Record which makes management of files to models really easy.

Recently while creating administration page for a model, in which Paperclip was being used for managing attachments, I oberved that Active Admin was not handling it properly. For example, the view page was showing as below:

Continue Reading »

OpenShift is Red Hat’s Platform-as-a-Service (PaaS) that allows developers to quickly develop, host, and scale applications in a cloud environment similar to Heroku. OpenShift also supports deploying of application with simple git push just like Heroku. OpenShift supports a variety of technologies through use of cartridges, including Java (Wildfly, JBossEAP, Tomcat), PHP, Node.js, Python, Perl, MySQL, PostgreSQL, MongoDB, Jenkins, Cron, and JBoss xPaaS Services (Fuse, BPM Suite, BRMS, Data Virtualization, Aerogear, and more).

Why OpenShift?

The free version of OpenShift, OpenShift Online, has many advantages over free tier of Heroku:

  • If application is not accessed for an hour on Heroku, web dyno goes to sleep mode making the next request take up to 30 seconds to serve leading users to abandon the site visit. OpenShift’s idling time is 24 hours and, as of my personal experience, it takes around 10 seconds for next request to serve.
Continue Reading »

Recently while working on a Rails project, I came across following markup for navigation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<ul class="sidebar-menu">
  <li class="treeview active">
    <a href="#">
      <span>Category</span>
    </a>
    <ul class="treeview-menu">
      <li class="active">
	      <a href="#">
	      	<span>Add Category</span>
	      </a>
      </li>
      <li>
	      <a href="#">
	      	<span>Update Category</span>
	      </a>
      </li>
    </ul>
  </li>
</ul>
Continue Reading »