The Fastest Way to Invoice Your Clients

Now we’re flying!

by Rich Lafferty - September 9/2008

For the last day or two we’ve received a number of reports that FreshBooks was running far slower than it ever had in the past. Given that this weekend we’d had some downtime to upgrade our infrastructure, things running slowly the first business day after that was the last thing we expected.

But there’s good news: after a long day of checking every corner, we managed to track down the problem to an unexpected bottleneck in MySQL. Clearing up that bottleneck has let us tap the full speed of our new
hardware.

Among other measurements, we monitor site performance by measuring the amount of time it takes to log in and send an invoice from various locations around the world. In the graph below you can see how eliminating that bottleneck has helped performance significantly:

FreshBooks is now running faster than ever. Thanks to those of you who struggled through yesterday with us.  We are now pleased to introduce you to our new hardware and the fastest running FreshBooks experience to date – enjoy!

For those curious about what happened, there’s some details under the cut.

The problem was caused by our new configuration of MySQL.  The usual approach to setting MySQL’s table cache size is to make it large enough that it can hold all of your tables open, but we have too many tables for that to be practical. Instead, we decided to make it big, to improve the odds that tables we need were already in the cache. And since we had new, bigger hardware with more RAM and faster disks, we decided to cache even more tables.

Unfortunately, while opening tables is fast in MySQL, the speed at which it can close tables gets slower and slower as the table cache grows. Linearly, in fact. And since the cache will always end up full, the speed that MySQL can close tables becomes the speed that MySQL can open tables. And to exacerbate the problem, opening and closing tables in MySQL uses a global lock, so only one thread can be opening or closing tables at a time, regardless of how many threads are executing in parallel.

Once we understood this, we realized that if the cache is going to be full, it needs to be kept as small as possible. We reduced it to the minimum we could get away with without having to reopen tables in the middle of one session interacting with FreshBooks. And now that closing tables is faster, everything’s faster.

The fastest way to track your time and invoice your clients is with FreshBooks, the leader in online invoicing. Sign up for your free account!

48 Comments (add comment)

Sep 9/08
1:49 pm
Randy says:

Nice Rich! Multi-colored charts are definitely helpful ;)

Sep 9/08
9:46 pm
Joe says:

I really appreciate the honest explanation and enjoy actually hearing the technical reason behind the problem. Most companies these days try to pass the blame off to someone else, and if they do admit to it, they don’t tell you WHAT caused the problem.

Hearing such a detailed and technical breakdown helps my confidence in FreshBooks because not only are you honest, but it shows me that you really know your systems and learned something at the same time. Plus I learned something too :)

Sep 10/08
7:11 am
Jeff Courteau says:

Nice job, and I appreciate it too when people are honest like that, it’s good to be making business with a company who cares about its client’s curiosity ;-)

Keep up the good works!

Sep 10/08
7:43 am
Tm Mahdi says:

Here Here :D

Sep 10/08
8:57 am
Leon says:

As a potential customer this explanation is a very refreshing change to the usual “it was the hardware” excuse carted out by most suppliers. Freshbooks is easy to use AND now its super quick. But as a techie myself I can’t help saying that MS SQL Server wouldn’t have had this problem ;) …. There would be many others.

Sep 10/08
9:50 am

Leon: One of our developers formerly worked on DB2 at IBM. I bet you can imagine some of the opinions he’s had on MySQL in the last couple of days! :-)

Sep 10/08
11:05 am
Tom says:

Hey, how can I become one of the folks that’s a green line on the chart?? Just kidding. Seriously though, this is a great improvement & we appreciate the openness with your clients.

Sep 10/08
12:34 pm

Oh, sorry, I could have labeled that chart better! The purple line is the relevant one — the time it takes to complete sending a new invoice.

The green line is DNS request time, and yellow is “first byte”. Purple is “full content”.

This chart’s just from one of the monitoring locations. Multiple locations is useful when we’re seeing different results from different places, but when we know it’s at our end we just pay attention to one (New York, in this case).

Sep 10/08
3:38 pm

You Freshbooks Guys are my Hero !!
Mike M for President in 2008

Sep 10/08
10:26 pm

[...] ran into an interesting bit about selecting a MySQL Table Cache size: The problem was caused by our new configuration of MySQL. The usual approach to setting MySQL’s [...]

Sep 11/08
7:51 am
francis says:

You guys simply rock…….!

Sep 11/08
3:01 pm

I found this claymation site that really helps give clear explanations of complicated issues.I know colored charts can help, but what if freshbooks was to implement a animation video that would help even the most elementary internet user gain a grasp of your technology. Just a thought.

Sep 12/08
4:30 pm

We’re a leadership development consultancy and I just wanted to take a chance to applaud your transparent handling of this issue. As others have said I can count on one hand the number of times a vendor has just explained the bare technical details to me. It’s much appreciated. I continue to be a big fan.

Sep 30/08
2:10 pm
Ron Paul says:

So that explains the slowness.

Oct 3/08
4:20 pm
sohbet says:

thanks for new. explanations of complicated issues

Oct 3/08
4:21 pm

bencede so that explains.

Oct 3/08
4:22 pm
kelebek says:

kelebek live Just kidding. Seriously though

Oct 6/08
9:43 am
sohbet says:

thank you very much for this article

Nov 18/08
2:04 pm
Adam says:

What software do you use for that testing?

Nov 18/08
2:07 pm

Adam: The graph above is from AlertSite, who we use for performance monitoring.

Nov 18/08
2:27 pm
Adam says:

Thanks Rich!

Nov 18/08
2:29 pm
Adam says:

While I’m asking, do you use Selenium or another front end testing tool for regression testing? We’re looking for something other than Selenium.

Nov 18/08
9:08 pm

table_cache is for MyISAM tables, I’m quite surprised you’re using MyISAM as your main storage engine – you mentioned invoicing, too.
MyISAM is not ACID compliant, and is not that safe with crash recovery (depends somewhat on the rest of the config, it’s not absolute anyway).
Therefore, with modern machines with enough RAM and such, InnoDB is generally recommended as the default storage engine.

With MyISAM you’re also relying on the disk cache for row-level caching, and of course there’s the table-level locking for updates/deletes; all this affects performance, in the latter case for reasons of concurrency bottlenecks.

Regards, Arjen.
Director, Open Query (http://openquery.com.au)
MySQL training & expertise

Nov 19/08
9:47 am
Momchil says:

Hey Adam,

Selenium is indeed a great tool for automated regression tests. It has a solid community and support base and lots of QA departments use it since it is free and at the same time provides a decent set of features.

If you would like to use something “more professional”, two good options are HP’s QTP (quick test pro) or Borland’s SilkTest. Those will definitely cost you money, but many would argue they are worth every penny.

Cheers,

Momchil

Nov 19/08
3:45 pm
Adam says:

Momchil,
Thanks, I’ll take a look at those two.

Best regards,
Adam

May 19/09
3:33 am
kabin says:

As a potential customer this explanation is a very refreshing change to the usual “it was the hardware” excuse carted out by most suppliers. Freshbooks is easy to use AND now its super quick. But as a techie myself I can’t help saying that MS SQL Server wouldn’t have had this problem ;) …. There would be many others.

May 19/09
3:34 am
su deposu says:

Selenium is indeed a great tool for automated regression tests. It has a solid community and support base and lots of QA su deposu departments use it since it is free and at the same time provides a decent set of features.

Jun 7/09
6:00 pm

Keep up the good works. it’s good to be making business with a company who cares about its client’s curiosity.

Jun 7/09
6:01 pm

[...] ran into an interesting bit about selecting a MySQL Table Cache size: The problem was caused by our new configuration of MySQL. prefabrik evler The usual approach to setting MySQL’s [...]

Jun 9/09
12:22 pm

As a potential customer this explanation is a very refreshing change to the usual “it was the hardware” excuse carted out by most suppliers. Freshbooks is easy to use AND now its super quick. But as a techie myself I can’t help saying that MS SQL Server wouldn’t have had this problem ;) …. There would be many others.

Jul 18/09
8:07 am
cinsellik says:

I am grateful to you for this great content.

Jul 20/09
2:22 am

Keep up the good works. it’s good to be making business with a company who cares about its client’s curiosity.

Jul 20/09
8:22 am
konteyner says:

Keep up the good works. it’s good to be making business with a company who cares about its client’s curiosity.

Aug 6/09
5:25 am

Seriously though, this is a great improvement & we appreciate the openness with your clients. Saç ekimi and saç ekimi merkezi

Aug 31/09
6:25 am

it’s good to be making business with a company who cares about its client’s curiosity.

Oct 13/09
4:06 pm
sohbet says:

While I’m asking, do you use Selenium or another front end testing tool for regression testing? We’re looking for something other than Selenium.

Oct 22/09
3:52 am
Tim says:

Freshbooks is easy to use AND now its super quick. But as a techie myself I can’t help saying that MS SQL Server wouldn’t have had this problem

Oct 22/09
3:53 am

thanks my friend

Oct 22/09
3:55 am
Kepenk says:

Momchil,
Thanks, I’ll take a look at those two.

Oct 22/09
3:55 am
Tatil says:

thanks good article

Oct 22/09
3:56 am
Balonlu says:

So that explains the slowness.

Oct 22/09
3:57 am

nice stie thanks

Oct 22/09
3:57 am

very nice work

Oct 23/09
2:42 am

thanks a lot 3

Oct 23/09
2:44 am
hediye says:

thank you
very good article

Oct 23/09
2:50 am

very good work
nice cars

Oct 23/09
2:52 am
trauringe says:

thank you
very nice wedding rings

Nov 2/09
6:39 am
AVUKAT says:

thank you
nice Adwokats


Leave a Comment

*
* (not published)

*
* required

What is FreshBooks?

FreshBooks is an online invoicing and time tracking service that helps professionals in over 100 countries save time, get paid faster, look professional and focus on what they love to do — their work. Read our customer survey results — 99% recommend FreshBooks. FreshBooks users are served by a tight-knit team of 31 dedicated individuals based in Toronto, Canada who've been at this since 2003.
Learn More or Sign Up For FREE

Get Blog Posts