ccb12 migrating from a scale-up relational database to a scale-out schema-less solution

20
1 Citywire – Oct 2012 For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. Migrating from a scale-up relational database to a scale-out schema-less solution

Upload: couchbase

Post on 17-Jun-2015

535 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

1Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way.

Migrating from a scale-up relational database to a scale-out schema-less solution

Page 2: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

The Company

• Founded in 1999 as a financial news website in the UK. Based in London

• Citywire is a growth company and today, we make money via online and print advertising, events and research across Europe and starting Q3, Lat. America and Asia

• At the start of 2012, we had thirteen people in the technology team

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 2

Page 3: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Technology we use

• Windows Servers• ASP.NET• MS SQL Server 2008 R2• Vmware Virtualisation• NetApp Storage• Couchbase noSQL

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 3

Page 4: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Where we were in 2011

• Rapid traffic growth• Time-outs• Server 500’s• Long loading times

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 4

Page 5: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

www.citywire.co.uk architecture

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 5

Page 6: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Where were the problems?

• Complicated SQL leading to poor query performance

• Single SQL server overloaded at busy times• ASP.NET Memory caching is inefficient• Complicated DAL code and often business

logic in SQL

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 6

Page 7: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Our codebase

• Technical Debt accrued over the years - Business logic all over the place, including in stored procedure

• ASP.NET Web Forms (with some MVC)• Synchronous messaging with WCF

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 7

Page 8: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

SQL Server

• Operational issues – single point of failure, maintenance jobs

• In team skills – we had no DBA, and our developers were strong in C# and ASP.NET

• Cost – every couple of years, we had been buying bigger and bigger servers

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 8

Page 9: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

ASP.NET Caching

• Consistency across web gardens and web farms

• ASP.NET Cache is lost when the worker process is restarted

• Cache size limitations, garbage collection, and large objects (http://www.simple-talk.com/dotnet/.net-framework/the-dangers-of-the-large-object-heap/)

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 9

Page 10: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Our solution to the problem

• Commitment to separation of concerns, MVC, IoC, dependency injection, and AOP

• CDN for static content• A distributed caching solution

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 10

Page 11: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

How did we do it?

• Built a Couchbase (membase) cluster• AOP - MS Enterprise Library’s Policy Injection

Handler• IoC and Dependency Injection - Structuremap• Left our CMS and processes working off the

SQL Server

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 11

Page 12: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Couchbase (Membase)

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 12

Page 13: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

What did it give us?

• Cache consistency across web farm and gardens

• Scalable cache size• But not resilience against single point of

failure for our main web site, we were only caching.

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 13

Page 14: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Global Growth in 2012

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 14

Page 15: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Architecting for 35 websites

• New codebase, with continued commitment to separation of concerns, MVC and IoC

• Asynchronous eventual consistency - NServiceBus

• Commitment to scaling out• Building a “single version of the truth” in the

form of schemaless documents stored in couchbase

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 15

Page 16: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Schemaless documents

• JSON, we used the JSON.NET serialiser (http://json.codeplex.com/)

• Moved all business logic to move into the “publishing” tier• Asynchronous publishing via nService bus, and continue to also

go to SQL• Conventions for modifying

document fields forbackwards compatibility

• Developers can stay in theircomfort zone of C# and awayfrom SQL

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 16

Page 17: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

How we are doing it ….

• Using Couchbase 1.8.1 in production and Solr for search.

• Started by caching the newly designed documents using existing methods by building code to create the document through existing services

• Created async publishing integration points to couchbase leaving existing SQL based applications to function

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 17

Page 18: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Publishing documents

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 18

Page 19: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Thanks for listening

• Truc Chu• [email protected]• http://www.linkedin.com/pub/truc-chu/

48/267/29b

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 19

Page 20: CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution

Citywire – Oct 2012For internal use only - no part of this report can be distributed to affiliate, subsidiary, parent or associated companies, to third parties or publicised in any way. 20