You are on page 1of 47

How MySQL and NoSQL Coexist

Matt Yonkovit - Percona

DIAMOND SPONSORSHIPS

THANK YOU TO OUR DIAMOND SPONSORS

www.percona.com

Who Am I
Matt Yonkovit - Principal Consultant Percona

MySQL- Sun !eteran

"#$ years %ata&ase 'xperience Lots o( (un at parties

What We do

Where MySQL and the Ecosystem is today

Lots o! Data

MySQL !oc"s sca#e "$


Look at t*e advances made wit*in innod&
,Scala&ility to -.$cores ,SS% en*ancements ,%ealin/ wit* me/a-si0ed &u((ers pools

1*is (its wit* *ardware


,Multi-core ,Lots o( memory standard ,C*eap 2las*

We Need More Ser%ers&

Ind"stry Says Sca#e O"t


Cloud Computin/

,3ise o( 'C. ,Scale on demand ,Pay (or w*at you need


4i/ companies run "5556s o( servers 4i/ %ata retention drives more scale out

,3etention and 7nalysis out pace *ardware /rowt*


1*is is part o( t*e cyclical nature o( computin/8 9 remem&er *earin/ t*is (rom :racle w*en 37C was (irst introduced8 &e(ore t*at it was time s*are

De%e#o$ers want easy and !ast


SQL 9s Power(ul 4ut SQL can &e overly complex (or many operations Sometimes :ptimi0ers in 3%4M6s do stupid t*in/s and developers can do it &etter SQL is yet anot*er component a developer needs to learn 'ven (or Simple SQL operations t*ere is over*ead to parse;execute

ORM S"c's
4ecause developers want to &e (ocused on &ein/ super developer nin<a6s = t*e o(ten turn to :3M6s :3M6s > like active record ? work /reat (or simple applications8 &ut tend to &ork w*en you *ave complex mappin/s

(ast Mo%in) Chan)es


)*at data and *ow t*at data is stored is c*an/in/ at a &reak neck pace C*an/es to lar/e data&ases are *ard
,'xample 9n a presentation Crai/slist said t*eir arc*ive d& took " mont* to alter a ta&le. ,:t*er alters can still take days or weeks

Missed o$$ort"nities
)*ile t*e MySQL community as a w*ole *as done an awesome <o&8 we did miss a (ew t*in/s+
:nline 1a&le 7lters > 7dd;Mod column ? Scale out -vs- Scale up 2lexi&le data types

How other )ro"$s tac'#ed the $ro*#ems

+he Rise o! NoSQL


3%4M6s o( old did not keep up wit* t*e demand Need (or (ast8 e((icient data access 'liminate t*e pain points 'liminate t*e unneeded (lu((
,Many we&sites /ot alon/ well wit*out t*in/s like 2unctions8 Stored porcs8 (ull acid8 compliance8 etc. ,

NoSQL Co%ers a #ot


@ey;!alue
,i.e. memcac*ed8 redis

Column Stores
,i.e. H&ase

%ocument Stores
,i.e. Mon/o8Couc*

More ,de%e#o$er- centric inter!ace


9nstead o( relyin/ on a SQL inter(ace many NoSQL solutions allow develoeprs to stay in code and directly access o&<ects usin/ t*eir pro/ramin/ lan/ua/e o( c*oice
,i.e. mon/od&6s <avascript inter(ace

7llow data to &e retrieved in an easily consuma&le (ormat


,i.e. <son8 &inary o&<ect8 etc

Sca#e o"t
3emove t*e complexities and automate s*ardin/ Make (ull use o( multiple servers (or complex tasks
,i.e. map reduce

7&ility to add servers on demand Support (or (ail-over and replication

Easy to chan)e
C*an/e is a certainty in li(e... Asers will demand itB Make sure t*at you are not &ound to a ri/id structure
,7llow (or c*an/es on t*e (ly C(lexi&le sc*emaD

C"stom (eat"res
7dd support (or (eatures missin/ in MySQL or t*at solve a speci(ic need
,Erid2S >Mon/o? ,Super Columns >Cassandra? ,Lists;Sets >3edis?

Where are we now. SQL /%s/ NOSQL.

+oo M"ch (0D


7 lot o( developers like to *ate on MySQL 7 NoSQL Solution >Like Mon/o? does not mean+

,You do not *ave to t*ink a&out your data types and Csc*emaD desi/n ,%oes not mean add nodes will solve all your issues ,%oes not mean you can /et sloppy wit* code ,)ill not (ully replace a relational d&
4ad Code is 4ad Code

As com$#ex as yo" ma'e it


You still *ave to t*ink wit* NoSQL
,How will t*is data &e used ,)ill we *ave to correlate t*is data wit* ot*er data in t*e system ,)ill duplication o( data cause issuesF 4loat spaceF

+oo M"ch (0D


7 lot o( people in MySQL *ate on NoSQL Not 7ll CN:SQLD solutions are made t*e same ,Some o( t*em are dura&le8 or are addin/ dura&ility (eatures > i.e. mon/o in ".G$ ? ,)*ile in most CN:SQLD more memory H &etter per(ormance8 t*e same *olds true (or MySQL ,Not every solution is eventual consistency 3emem&er MySQL started as Ct*at ot*er tec*nolo/yD8 mocked &y classic %476s Many o( t*ese solutions are at similar places w*ere MySQL was I-J years a/o.

MySQL is not Sittin) Id#e

Lessons !rom ND1


9n Many ways MySQL *as *ad a CNoSQLD solution availa&le (or years N%4 > MysKl Cluster ? is at its code a CNoSQLD solution wit* a SQL wrapper Many deployments o( N%4 need to &ypass t*e SQL layer and write directly to t*e N%4 7P9 in order to ac*ieve optimal per(ormance

Parsin) SQL Can *e s#ow


li&mysKl >7kiraLs Num&ers? samples M JNG5.. ."PJ5. .5#I5I "PG.-N sym&ol name MYSQLParse>voidO? myQpt*readQ(astmutexQlock makeQ<oinQstatistics>=? &trQsearc*Q/uessQonQ*as* J.J-## ...J.5 ..".I. ..5#55

Sources+ http://www.mysqlperformanceblog.com/2011/03/16/where-does-handlersocket-really-save-yout me/ http://www.sl deshare.net/ak rah guch /handlersocket-2010062!en-"6!#21"

Hand#er Soc'et
%eveloped &y %eN7 %irect 7ccess to t*e 9nnod& stora/e en/ine8 &ypassin/ SQL @ey-!alue type access Yos*inori *it J#5@ QPS8 (aster t*en memcac*ed8 and JR (aster t*en Stock SQL

*ttp+;;yos*inorimatsuno&u.&lo/spot.com;.5"5;"5;usin/-mysKl-as-nosKl-story(or.*tml

Hand#er Soc'et Per!ormance

4enc*mark &y !adim+ *ttp+;;www.mysKlper(ormance&lo/.com;.5"5;"";5.;*andlersocket-on-ssd;

Memcached
:racle recently /ot in on t*e (un8 introducin/ a Memcac*ed inter(ace (or 9nnod& @ey-!alue access Ases li&memcac*ed > known and used protocol? Promise t*e a&ility to use t*e distri&uted *as* capa&ilities o( memcac*ed to s*ard > not availa&le yet ?

Q"estion Sho"#d yo" "se MySQL or Loo' at NoSQL So#"tion.


Answer It de$ends on yo"r a$$#ication2

Q"estions yo" sho"#d as'


%o you need transactionsF Can you risk data lossF )*at are your per(ormance reKuirementsF )*at level o( risk is accepta&leF Costs involvedF

Hard costs+ Servers8 9n(rastructure So(t costs+ %eveloper 1ime

3enera# MySQL Considerations


%ura&ility important > 9s some data loss accepta&leF ?

-rd Party applications 9nte/ration wit* ot*er 3%4MS6s 7lready invested in SQLF :L1P type )orkloadsF 1ransactions Soins

3enera# NoSQL Considerations


SQL 9s :verkill

,Simple @ey !aluesF


%ocument :riented

,No Standard 2orm or Consistent data stream


3eKuire CPA 4ased resources (rom several mac*ines Hu/e amounts o( arc*ived data 3apid C*an/es to t*e structures Possi&le data inconsistencies

,'ventual consistency &y product

Per!ormance.
Per(ormance (or &ot* MySQL and NoSQL solutions can vary wildly. 9mpacted &y+

,Sc*ema;:&<ect desi/n ,%atatypes ,9ndexes ,:3M ,%rivers


You can in many cases you can trade per(ormance (or relia&ility;consistency

S$ace
)it* Hu/e %atasets8 space can &e a premium Some NoSQL options can take up a lot more space t*en t*eir MySQL counter parts. RML 'xample >no redundant data?+
,..#E4 in Mon/o%4 ,NGIM4 in 9nnod&

Some solutions *ave you duplicate data (or per(ormance and simplicity

+ho" sha## 1enchmar'


1rust8 &ut veri(y

4eri!y
9 *ave run into a lot o( people w*o leap &e(ore t*ey test
,7skin/ (or trou&le

%on6t &e trapped &y le/acy pro&lems


,9( you *ave &ad sKl code8 its not MySQL6s (ault T?

Ase speci(ic &enc*marks8 not /eneric ones

NoSQL O$tions

Mon)oD1
Nice Sson centric data stora/e
,%o not underestimate

No Native Soins 1rade per(ormance (or consistency %ata (ootprint can &e &i//er t*en MysKl in some cases

Map3educe capa&ilities 4etter dura&ility in version ".G$ 4uilt in s*ardin/ 3eplication

Redis
Pros: 2ast w*en (ully in memory8 &ut can use Cvirtual memoryD Supports Cclusterin/D Supports replication Super (ast Complex data types like lists Cons: Asin/ !irtual Memory prevents usin/ ot*er (eatures %ata loss possi&le No Native <oins @ey 7ccess only

Cassandra
Pros: 7uto-S*ardin/ o( data 3eplication Parallel Processin/ Super Columns are interestin/ Cons: 'ventual Consistency %ocumentation not as deep as ot*er solutions Speed is &y product o( addin/ more nodes Network C*atty %ura&ility issues

Hadoo$
Pros: Ereat wit* Super Lar/e %atasets >Peta&ytes? 'xtreme Parallelism Can do complex CPA intensive tasks via map reduce Cons: Can &e complex Needs time to produce results No Native Soins;9ndexes

+o'yo Ca*inet
Pros: Can 4e Super 2ast Cons: No 4uilt in S*ardin/

Multiple 1a&le 1ypes to %ura&ility;Consistency issues support di((erent reKuirements Lack o( %ocumentation 'm&edda&le Can 4o/ down i( you run out 3eplication o( memory Can use Memcac*ed protocol

Co"ch
3esistant to corruption M!CC 4ased >!ersionin/? Savascript 3est 9nter(ace 3eplication Map 3educe 'asy to Eet started No S*ardin/ Can &e slower t*en ot*er solutions

MySQL +ric's
1*ere are ways to solve t*e CNoSQLD issues in MySQL8 &ut t*ey are manual or add complexity
,Stora/e en/ines ,S*ard Query ,RML %ata ,S*ardin/ ,N%4;Cluster

You might also like