Full-time Startup: Skribit Week 12 (Scaling)

April 1, 2009 · 34 comments

My last startup update discussed Skribit’s recent redesign and entrance into the GRA/TAG Business Launch competition. Since then a few things have been keeping us busy. For one, we have had more and more server issues. While Skribit doesn’t use much in the way of CPU resources, it can take all the RAM it can get. That being said, we’ve had a few annoying downtime episodes in the recent past.

Scaling Step 1: Find Your Bottlenecks (Assess Your WTFs)

Up until now (well still now but not for long after this post is published) Skribit has been using a MediaTemple (dv) server with 1.3GB of physical RAM, 40GB of hard drive space and dual dual-core Xeon processors in an HP Proliant G4 server running Ubuntu. With each mongrel and mysql instance using around 60MB of RAM each, Skribit easily came to be very memory hungry.

Of course there are always things you can do before upgrading hardware that will help you scale, and that’s best practice. Things like memcached as well as caching frequently accessed items or slow queries. We actually ran into an issue of fragment caching too much and it was eating up a good bit of RAM, but I digress. The first thing you need to do is find out why your app is getting slower and slower and your server can’t keep up anymore.

For that, we use a myriad of Unix system administration and Rails monitoring tools:

Skribit Server RAM Usage before scaling
I love htop.. put it on all my linux boxes.
Skribit Monit
Monit tracks processes and restarts them if they get unruly.. which happens often. For example, it will restart a mongrel that meets this criteria: “If Memory amount limit (incl. children) greater than 66560 1 times within 1 cycle(s) then restart else if passed 1 times within 1 cycle(s) then alert”

We used to use exception logger but switched to Hoptoadapp after exception logger started using some resources (we started seeing some items from the slow query log coming from exception logger), and we like Hoptoad.

Hoptoad App Showing Skribit Exceptions
Hoptoad App telling us what exceptions need to be fixed. Click the image for more detail.
Skribit status with New Relic RPM
Some example reports from the free version of New Relic RPM
Fiveruns Tuneup with Skribit localhost
Fiveruns TuneUp telling me what takes up the most time on a page load and breaks it down by MVC. It also lets you click on any action and opens up the responsible file to the exact line in your default text editor. Calvin has a guide for using TuneUp in a separate environment.

Do you use any similar server/app monitoring tools?

Scaling Step 2: Drink What does it all mean?

So you have more information than you know what to do with, now what? If your data is anything like ours, there isn’t just one magical fix. It’s an ongoing process and there are tons of individual cases where certain pieces of code could do things in a more efficient manner. Or you might be realizing that your entire code base needs some restructuring and a better database design. Sorry if that wasn’t the answer you were looking for; scaling isn’t easy. Fortunately all of those tools make it pretty easy to identify where things are slowing down.

And if you are on top of your bug fixes and small performance tweaks and your app/server combo is still failing you, there are more intricate setups involving things like Varnish HTTP accelerator, database denormalization, database sharding, master-slave database setups, load balancing, global queuing and other such terms that will make your lead dev/sys admin/DBA want to hit the bar. Skribit is still pretty young so we have yet to tackle any overly-complex solutions for the sake of performance, but it’s definitely in our near future.

While we’re on the subject of scaling, I’d like to point out an old but tried and true post by Rails creator DHH. The context is that it’s cheaper to pay for more server resources and a developer that’s more productive from using enjoyable and easy-to-use tools and languages like Ruby:

The point is that the cost per request is plummeting, but the cost of programming is not. Thus, we have to find ways to trade efficiency in the runtime for efficiency in the “thought time” in order to make the development of applications cheaper. I believed we’ve long since entered an age where simplicity of development and maintenance is where the real value lies.

Getting back on track, some things don’t change and sometimes you just need better hardware as your web app grows faster than you can speed it up and squash slow queries. We have been working closely with Media Temple (shameless plug… the same and only host I’ve been using since 2005) and we are now configuring a new 2 server CentOS setup. More on that later as Calvin gets it up and running. With our new setup we will be trying something completely different and give Apache with Phusion Passenger a shot, alongside Ruby Enterprise Edition.

2 MediaTemple Dedicated Virtual Servers

In a nutshell, one box will run the bulk of the app server while the other will doing the database grunt work in addition to running a little bit of the app as well.

What should you take away from this? Not much. I’m just spewing stuff that’s flying around in my head. We are at the tip of the iceberg for Skribit scaling and I’m sure I’ll have more interesting things to say about future scaling headaches. But if you like reading about technical issues like scaling like I do here are two presentations on scaling: one from Scribd themselves and one from another Rails coder.

Have you ever had to deal with scaling issues for your app or site?

On the business side of things..

Skribit Business Plan Draft in Microsoft Word Mac 2008The business plan due date (April 7th) for the GRA/TAG Business Launch competition is nearing. When not battling Microsoft Word 2008’s annoyances (I started writing in Google Docs but needed some more advanced Word features unfortunately), I’m describing who we are, what we do, how people will find us, why people will use us, how we’ll make a return on investment and how we are different from our competitors. I started off with the competition’s judging criteria and began filling out the sections:

I. Market
a. Clear pain in the market
b. Market Overview
i. Size of the market
ii. Initial Target market
c. Competition
i. Current solutions
ii. Future solutions
iii. Barriers to Entry
iv. Competitive advantage
d. Sales and Channel strategies

II. Technology
a. Differentiation
b. Source of Intellectual Property
c. Protection of Intellectual Property
d. Development plan
e. Scalability

III. Management/Organizational structure
a. Management
b. Board of Directors
c. Advisory Board

IV. Money
a. Financials (3 years)
b. Revenue Model
c. Investment Needs
i. Current investors
ii. Fundraising
1. How much do you need
2. How long will it carry you
3. What you plan to do with funds
iii. Exit strategies

And now I’m going back and adding detail; I’m somewhere around 14 pages now and I have yet to stick in relevant graphs and screenshots that illustrate how Skribit works. The next step is getting business plan draft feedback from Lance Weatherby (Skribit uber advisor) and Scott Burkett (assigned competition mentor and local entrepreneur of StarPound) and overhauling the business plan. I have a tendency to dumb things down a ton, which can be good at times, but I have a feeling the type of people that will be reading this business plan will expect it to be formal and have fancy words like synergy, core competencies, mission-critical, incentivize, supply chain, rollout, SWOT and paradigm shifts.

For those in the same boat, Mahalo has a ridiculously comprehensive How to Write a Business Plan page.

Overall

Skribit is in a pretty interesting position right now and I’m eager to see where we’re headed. If I had one complaint though, it’s that I can’t clone myself (yet) and get things done faster. This business stuff is interesting and I love writing down everything we plan on doing in detail and elaborating on our bigger picture, but I want to get back to coding.. I was just getting the hang of this Rails thing.

Thoughts? How is your startup going?

PaulStamatiou.com runs on the Thesis Theme for WordPress

How smart is your Theme?  How good is your support? Check out ThesisTheme for WordPress.

Thesis is the search engine optimized WordPress theme of choice for serious online publishers. If you’re a blogger who doesn’t understand a lot of PHP, Thesis will give a ton of functionality without having to alter any code. For the advanced, Thesis has incredible customization possibilities via Thesis hooks.

With so many design options, you can use the template over and over and never have it look like the same site. The theme is robust and flexible enough not only to accommodate a site like PaulStamatiou.com, but also to enable the site to run far more efficiently than it ever has before.

{ 34 comments… read them below or add one }

1 M Dolon April 1, 2009 at 2:33 am

Hey Paul, glad to see Skribit is going well. Quick question – how many people are currently working on it at the moment?

I’m currently working on two startups – one that is online-based and the other a real world, social entrepreneurial project. The latter is part of a business incubation program and we’ve spent the past several months doing a feasibility analysis, business model, financial model and writing the business plan. In other words, I feel your pain man!

We are applying to some local business plan competitions too – best of luck with yours!

Reply

2 Paul Stamatiou April 1, 2009 at 2:41 am

I’m the only full-timer on Skribit and Calvin/@cyu is also a co-founder but works part-time now. We also have @lance as our ever helpful and resourceful advisor.

Reply

3 Jordan April 1, 2009 at 2:38 am

Are you running 12 mongrels on one server? If so, that’s the cause of your memory problem. You could probably get by on 3 instances.

Reply

4 Paul Stamatiou April 1, 2009 at 2:40 am

Yeah we are running a few mongrels.. we temporarily take down a few when we really get memory constrained. Skribit serves a lot of widgets (several million widget pageviews/month) so the extra mongrels really come in handy.

Reply

5 Chris Boulton April 1, 2009 at 5:20 am

Paul,

Have you considered switching to Apache, Passenger and Enterprise Ruby? I think you’ll end up being rewarded by the benefits – no more watching for Mongrel processes gone rogue etc, lower overall resources & memory usage, pages being served up quick etc. Have recently switched a few things over, and have really started noticing the benefits under high load.

Also curious if you’ve looked in to making sure that you don’t have bottlenecks with your MySQL configuration? (that is, it’s properly configured for the amount of resources you want allocated to MySQL). For that, things like mytop, Maatkit, mysqlsla and the fantastic mysqltuner.

Of course, there’s no doubt you need more than 1.3 GB ram – I’d settle for no less than 4 GB these days. Especially with the amount of dynamic content you’re serving up.

Have you looked in to totally dedicated machines? For the cost you’re paying with MT at the moment (assuming you don’t have some sort of deal with them ;)), you should be able to pick up a pretty decently spec’d server from SoftLayer – and if you use their YIPP promo code, double the RAM and HDD space for nothing.

(Keep up the blog posts like these – love them and love hearing about what other people are using)

Reply

6 Paul Stamatiou April 2, 2009 at 11:55 pm

Yeah I mentioned it a bit later in the post, but our next setup is definitely gonna have Passenger & Ruby Enterprise. I can’t wait to get it all set up!

Reply

7 dabent April 1, 2009 at 10:14 am

“several million widget pageviews/month”

That’s pretty cool! I’m really liking the way you’re adding to Skribbit all the time. I likely need to upgrade my widget.

So are you daring enough to show your business plan to the word?

Reply

8 Knox Massey April 1, 2009 at 12:47 pm

Keep biz plan simple. Tell what it is, what it does, and who you are (founders). Keep buzzwords to a minimum. (When you find an advisor/investor that knows the tech, use them then.) Follow directions for GRA, that’s what they’ll be looking for. You’ll be fine.

Reply

9 Steve April 1, 2009 at 5:56 pm

Great post Paul. I looked into using Monit but was concerned about using the console over the internet from a security standpoint. Did you lock down access to the Monit console and only allow your specific IP address?

Reply

10 Paul Stamatiou April 1, 2009 at 5:57 pm

Our monit requries HTTP auth to use it but isnt locked to certain IPs as multiple ppl here need access to it.. but I’m sure that can be arranged too.

Reply

11 Jamie April 2, 2009 at 10:49 pm

Hi Paul. I’m just curious if you’ve ever considered rewriting some of your backend code in another language, such as Scala?

I know Twitter has moved their message queuing system to Scala because Ruby just couldn’t handle the load. Also, the creator of the Lift framework (a Scala web framework) claimed to get a 20x performance boost using Lift instead of Rails.

Reply

12 Paul Stamatiou April 2, 2009 at 11:56 pm

Jamie – I’m sure we’ll hit a point where scaling is a huge issue and that will have us reconsider how some things are built. That being said, for polling issues we have been looking at Rails Metal http://weblog.rubyonrails.org/2008/12/17/introducing-rails-metal for the near future.

Thanks for stopping by!

Reply

13 Joel April 3, 2009 at 12:15 am

Have you considered using Slicehost for your dedicated VPS? Your current hosting provider MT’s $50 plan seems pretty expensive for 256 MB RAM — you can get the same thing for $20 at Slicehost.

Also, what about Amazon EC2? You can scale easily with them and with their Elastic Block Store (EBS) it’s easy to operate MySQL with simple backups of disk-based data stores.

Anyway, Skribit is cool, good luck! Thanks for your blog on scaling, it’s interesting.

Reply

14 Paul Stamatiou April 3, 2009 at 12:26 am

Hey Joel – thanks for the comment. Media Temple has been helping us out on the cost front with Skribit during our startup phase and it’s been working out really well. I’ve been on (mt) for years and really love how I get the control I need, root access and all.. but I can call them up when I bork something haha.

That being said, if we had to host elsewhere and had the money, I
would definitely opt for a complete EC2 setup. I’ve tinkered with ec2 in
the past before
and they’ve done some amazing things in the last year that make it a
great platform.

Paul

Reply

15 lewro April 4, 2009 at 2:56 pm

Looking at the problems you are trying to solve sounds like you have good traffic so your project is going the right direction. Wish you like with the biz plan. Fingers cross.

Reply

16 Brandon April 6, 2009 at 12:20 pm

I think you should a cost/benefit analysis between investing a lot of time in reducing memory usage and just buying more RAM. Hardware is cheap; your time is not!

Reply

17 Paul Stamatiou April 6, 2009 at 12:24 pm

Agreed – although scaling is both a software and hardware issue. Upgrading hardware is cheap and pays off now. Software isn’t and keeps paying off. You need to do both when you are able to. ;D Reminds me of that demotivation poster for procrastination: “hard work often pays off after time, but laziness always pays off now”

Reply

18 Malcolm Jones April 8, 2009 at 11:16 am

Paul,

Fantastic article. As I told you before man, these blogs are really inspiring to us guys with our own start ups. I’ve been working on mine since January, and hopefully the private beta version will be out by May (fingers crossed), so I haven’t had to deal with scaling yet. However, I know that will be the case in the future, and it’s nice to know that I can come back here to read up on where to start.

Couple questions:

1. Right now I am a solo act…How do you like working with a team?
2. How did the GRA/TAG Business Launch competition go?

Like I said, love these posts. Keep them up!

Malcolm

Reply

19 Paul Stamatiou April 8, 2009 at 11:19 am

Thanks for stopping by Malcolm.

1) I’m kind of in a similar situation, I work from home by myself all day, but I’m always wired up via Campfire to Calvin so it’s very easy to bounce ideas back and forth and get quick feedback/help. Definitely more efficient.

2) Well I finished all the requirements and submitted them.. so we’ll see what happens!

Reply

20 oneighturbo May 26, 2009 at 4:19 pm

Just added Skribit back to the site! Hope to get some traction on it.

Reply

21 Scott Burkett May 28, 2009 at 11:31 am

Hey Paul – great post! I hadn’t heard of htop until your post, but after looking at it, I’m hooked. :)

Here is an old post of mine from two years ago. Paul’s post has a lot more current info in it, but this might be of interest/value to others:

http://www.scottburkett.com/index.php/technology/2007-01-08/scaling-your-technology-with-your-business.html

Cheers.
Scott

Reply

22 k00pa September 26, 2009 at 5:33 am

That htop image is awesome :D

Reply

23 PStamatiou April 1, 2009 at 2:23 am

dear twampss, i don’t know what you’re doing but I clicked publish on my blog 15 seconds ago and this was already posted here… it’s kind of annoying. this has been the case for every single blog post of mine in recent past. sounds like you’re using some RSS auto-posting script..

This comment was originally posted on Hacker News

Reply

24 mdolon April 1, 2009 at 2:36 am

What’s more interesting is that there is really no benefit of doing so other than karma-whoring.. I wonder what his agenda is if he’s using an auto-posting script.On the flip side, I got to read your article and commented on it!

This comment was originally posted on Hacker News

Reply

30 bsaunder April 1, 2009 at 8:08 am

Yeah, he could at least put an artificial delay in there. ;)

This comment was originally posted on Hacker News

Reply

31 mcav April 1, 2009 at 9:07 am

Check your web server referrer logs, you might be able to see which IP grabbed the RSS feed so quick and prevent it in the future. (That is, if twampss doesn’t respond here.)

This comment was originally posted on Hacker News

Reply

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: