最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

HowFreshdeskScaledItsTechnology(PartI)–BeforeShard_MySQL

来源:懂视网 责编:小采 时间:2020-11-09 19:11:35
文档

HowFreshdeskScaledItsTechnology(PartI)–BeforeShard_MySQL

HowFreshdeskScaledItsTechnology(PartI)–BeforeShard_MySQL:[Edit Notes: Three year old startup Freshdesk built out of Chennai, is now clocking 70 million app views per week. The company is growing fast. In this post, its operations head Kiran talks about how they scaled the technology backend.]Ever
推荐度:
导读HowFreshdeskScaledItsTechnology(PartI)–BeforeShard_MySQL:[Edit Notes: Three year old startup Freshdesk built out of Chennai, is now clocking 70 million app views per week. The company is growing fast. In this post, its operations head Kiran talks about how they scaled the technology backend.]Ever
[Edit Notes: Three year old startup Freshdesk built out of Chennai, is now clocking 70 million app views per week. The company is growing fast. In this post, its operations head Kiran talks about how they scaled the technology backend.]

Every startup’s fondest dream is to somehow grow exponentially but still stay nimble and super efficient. However that’s easier said than done. The 32GB RAM that is more than capable of handling the load today is going to look like a joke a week later. And with the financial freedom of a startup, you can only take one step at a time.

At Freshdesk, our customer base grew by 400 percent in the last year. And the number of requests boomed from 2 million to 65 million.

Freshdesk Growth

These are really cool numbers for a 3-year-old startup but from an engineering perspective, it’s closer to nightmare than dream come true. We scaled left right and center (but mostly upwards) in a really short amount of time, using a whole bunch of vertical techniques. Sure, we eventually had to shard our databases just to keep up, but some of these techniques helped us stay afloat, for quite a while.

Moore’s way

We tried to scale in the most straightforward way there is, by increasing the RAM, CPU and I/O. We travelled from Medium Instance Amazon EC2 First Generation to High Memory Quadruple Extra Large. It effectively increased our RAM from 3.75 GB to 64 GB. Then we figured that the amount of RAM we add and the CPU cycles do not correlate with the workload we get out of the instance. So we stayed put at 64GB.

The Read/write split

Since Freshdesk is a heavy read application (4:1; end user portals, APIs and loads of third party integrations tend to do that to you), we used MYSQL replication and distributed the reads between master and slave to accommodate them. Initially, we had different slaves getting selected for different queries using a round robin algorithm, but that quickly proved ineffective as we had no control over which query hit which DB. We worked around this by marking dedicated roles for each slave. For example, we used a slave for background processing jobs and another for report generation and so on (Seamless Database Pool, a Rails plugin, should do the job but if you’re an Engineyard user, I’d suggest you check out this cookbook).

As expected, the R/W split increased the number of I/Os we performed on our DBs but it didn’t do much good for the number of writes per second.

MySQL Partitioning

MySQL 5 has a built-in partitioning capability so all you have to do is, just choose the partition key and the number of partitions and the table will be partitioned, for you, automatically. However, if you’re thinking about going for MySQL partitioning, here are a couple of things you should keep in mind:

1. You need to choose the partition key carefully or alter the current schema to follow the MySQL partition rules.

2. The number of partitions you start with will affect the I/O operations on the disk directly.

3. If you use a hash-based algorithm with hash-based keys, you cannot control who goes where. This means you’ll be in trouble if two or more noisy customers fall within the same partition.

4. You need to make sure that every query contains the MySQL partition key. A query without the partition key ends up scanning all the partitions. Performance takes a dive as expected.

Post-partitioning, our read performance increased dramatically but, as expected, our number of writes didn’t increase much.

Caching

Some objects like support agent details change only 3-4 times in their lifetime. So, we started caching ActiveRecord objects and as well as html partials (bits and pieces of HTML) using Memcached. We chose Memcached because it scales well with multiple clusters. The Memcached client you use actually makes a lot of difference in the response time so we ended up going with dalli.

Distributed functions

Another way we try to keep the response time low is by using different storage engines for different purposes. For example, we use Amazon RedShift for analytics and data mining and Redis, to store state information and background jobs for Resque. But because Redis can’t scale or fallback, we don’t use it for atomic operations.

Scaling vertically can only get you so far. Even as we tried various techniques, we knew it was only a matter of time before we scaled horizontally. And the rate at which we were growing didn’t give us much time to ponder over whether it was a good decision or not. So before our app response times could sky rocket and the status quo changed, we sharded our databases. But that story’s for another day.


Further reading

About MySQL partitioning

Scaling of Basecamp

Mr.Moore gets to punt on Sharding

[About the Author:Kiran is the Director of Operations atFreshdesk. He calls himself the guy you should be mad at when the application is down. Reproduced with permission fromFreshdesk blog.]

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

HowFreshdeskScaledItsTechnology(PartI)–BeforeShard_MySQL

HowFreshdeskScaledItsTechnology(PartI)–BeforeShard_MySQL:[Edit Notes: Three year old startup Freshdesk built out of Chennai, is now clocking 70 million app views per week. The company is growing fast. In this post, its operations head Kiran talks about how they scaled the technology backend.]Ever
推荐度:
标签: mysql how before
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top