Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When people talk about scaling a website with 'shards', what do they mean?

I have heard the 'shard' technique mentioned several times with regard to solving scaling problems for large websites. What is this 'shard' technique and why is it so good?

like image 330
Phil Wright Avatar asked Sep 18 '08 11:09

Phil Wright


2 Answers

Karl Seguin has a good blog post about sharding.

From the post:

Sharding is the separation of your data across multiple servers. How you separate your data is up to you, but generally it’s done on some fundamental identifier.

like image 164
Oded Avatar answered Oct 14 '22 01:10

Oded


In brief, imagine seperating your users_tbl across several servers. So Users 1-5000 and on Server 1, Users 5000-10000 on Server 2; etc. If your data model is sufficiently abstract in code, it's often not a huge change in code.

Of course this approach becomes difficult if all your queries are similar to "SELECT COUNT(*) FROM users_tbl GROUP BY userType" but when your where is "WHERE userid = 5" then it makes more sense.

like image 35
Tom Ritter Avatar answered Oct 14 '22 00:10

Tom Ritter