Hi
everyone,
My
name is Michael Solovyov and I’m the co-founder & CTO of a
rails-based start-up. We have built a product for other businesses
to help their users adopt their products.
We’ve
built the application, delivered to a few customers and now we’ve hit
scaling and performance issues.
I’d
love your feedback on how we proceed as we try to resolve them:
These are the problems we’ve encountered:
The
main user dashboard takes between 7-15 seconds to load. The maximum
requests per second that we can support are 100-150.
Why we think they’re happening:
We’re using
couchdb with an ORM that has our data modeled relationally. This
causes the ORM to launch an extraordinary amount of http requests to
couchdb to load all our data. The more data and users in the project,
the longer the delay. There’s also potentially inefficient code,
extra loops etc. We’re not using caching to it’s fullest extent.
What we’re using/what we’ve done:
Our architecture:
rails ‘3.2.12’, ruby 1.9.3p374, nginx + unicorn (main server),
elasticsearch (separate server), couchdb (separate server). All on
AWS.
We’ve added some
view level caching where we can get away with stale data.
We’ve tried using
higher tiered/ssd aws servers but it doesn’t look to be our main
bottleneck.
How we plan on completing it:
We’re mostly done
a rewrite to migrate our data and data model to activerecord. We’ve
hit a snag in migrating s3 attachment code built into the couchdb ORM
that we’re using. Following the completion of the migration to
sql/activerecord we are going to do the following in an attempt to
increase performance:
A. Use
percono mysql server.
B.
Run tools such as bullet to analyze performance and where we might
have bad queries/lookups.
C.
Update to latest Rails and Ruby versions.
D.
Look into Puma and paralelization of DB access
calls.
E.
Break apart the application into separate services.
What we don’t know right now:
Whether switching
to Activerecord or any of the above ideas will inherently give us any
performance benefits.
Whether we will
have any other unexpected surprises or loss of functionality due to
switching to ActiveRecord.
How long this all
will take and whether there’s other areas that we need to focus to
get sub 1 second performance that we’re missing.
Do
you all have any feedback/ideas/insights completing projects like
these?
In
particular, I would be curious about:
a)
How would you approach it?
b)
Anything that’s worked for you in the past on suitable projects?
c)
Anything to avoid doing?
d)
Where to find good additional team members & advisors to help us
complete the project?
e)
How long to expect it to take?
Here
are our application rake stats:
http://pastie.org/private/qrxkytk4uur9odndydv5dq