CCB12 Migrating from a scale-up relational database to a scale-out schema-less solution
Transcript of 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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