Successfully reported this slideshow.

C* Summit EU 2013: Delivering Christmas Gifts in France Since 2012

3,481 views

Published on

Speaker: Matthieu Nantern, Software Engineer at Xebia
Video: http://youtu.be/ci9lrViHE9E
Every year more and more people buy their Christmas gifts online and that gifts are delivered by the postal service of France "La Poste". At the end of the infrastructure a (not so) little MySQL was struggling for survival against that overwhelming load. Then, in 2011, MySQL hit its limit... Come hear the true story of La Poste switching its parcel management, PHP-based application, from MySQL to Cassandra in 3 weeks. You'll be taught about the details of the project constraints, how to use Cassandra from PHP, the migration plan, how to manage resilience testing, deploy your Cassandra with Puppet, and all the wonderful knowledge we accumulate through this project.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

C* Summit EU 2013: Delivering Christmas Gifts in France Since 2012

  1. 1. Cassandra Delivering Christmas gifts in France since 2012
  2. 2. Me, myself and I Puppet Software Cassandr a Matthie u Nantern @mNantern mnantern@xebia.fr | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 2
  3. 3. From Mysql to Cassandra Overview 1 2 3 4 Context Why ? How ? Go Live! Delivering parcels at La Poste Why do we need another system ? Project’s constraints and alternatives How we build our solution. Using C* with PHP and managing TTL Provisioning servers. Performance and resilience testing | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 3
  4. 4. La Poste Mail services Parcels distribution More than 250 000 employees 70 000 postmen delivering parcels | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 4
  5. 5. La Poste Postman’s tour (1) A postman scans every parcels Print Scan (2) He prints his list of parcels (3) He distributes the parcels (4) He scans every remaining parcels Scan Distribute | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 5
  6. 6. From MySQL to C* Why ?
  7. 7. Why do we need another system ? | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 7
  8. 8. Project’s constraints Max 13ms per call 15 days of retention for data Easy to deploy and operate Easy to scale for years to come | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 8
  9. 9. From MySQL to C* How ?
  10. 10. Data Modeling Id Data key1 key2 key3 Id Data Search1 Search2 1 <Xml> k11 k21 k31 1 <Xml> k11k31 k21k11 2 <Xml> k12 k22 k32 2 <Xml> k12k32 k22k12 3 <Xml> k13 k23 k33 3 <Xml> k13k33 k23k13 | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 10
  11. 11. Using Cassandra with PHP For dummies $pool = new ConnectionPool("Keyspace1", array("cass:9160") $column_family = new ColumnFamily($pool, 'ColumnFamily1'); $column_family->insert('row_key', array('name1' => 'val1', 'name2' => 'val2')); $column_family->get('row_key'); $row1 = array('name1' => 'val1', 'name2' => 'val2'); $row2 = array('foo' => 'bar'); $column_family->batch_insert(array('row1' => $row1, 'row2' => $row2); | http://blog.xebia.fr | #CassandraEU www.xebia.fr | Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 11
  12. 12. Using Cassandra with PHP Level 2 $index_exp=CassandraUtil::create_index_expression($inde xName, $indexValue,$operator); ! ! $index_clause = CassandraUtil::create_index_clause($indexArray); ! ! $rows = $columnFamily>get_indexed_slices($index_clause); | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 12
  13. 13. TTL in C* $cf->insert('row_key', array('col1' => 'col_val1','col2' =>'col_val2'),null,TTL); $columnsTTL = array('col1'=>3, 'col2'=>4); ! $cf->insert('row_key', array('col1' => 'val1','col2' =>'val2'),null, $columnsTTL); | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 13
  14. 14. From MySQL to C* Go Live!
  15. 15. Provisioning C* with Puppet •12 servers with Ubuntu 10.04 ! package { 'cassandra': ensure => installed } initial_token: <%= ((2**127) * (current_cdb_server.to_i-1) / cdb_servers_number.to_i ) %> | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 15
  16. 16. Provisioning C* with Puppet Managing the data model package { 'cassandra-data-model': ensure => latest } migration_1.txt migration_2.txt migration_3.txt migration_4.txt Current Migration Id 2 | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 16
  17. 17. Testing our cluster Mysql performance | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 17
  18. 18. Testing our cluster Cassandra performance | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 18
  19. 19. Testing our cluster Resilience | www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 19
  20. 20. Migration plan t=0 t+15d Read Write | Read Write www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 20
  21. 21. From MySQL to C* Final words
  22. 22. THANK YOU For watching Merci!
  23. 23. Thanks ! Thank you for trusting me on Cassandra (and everything else)! Thank you for the support ! | Thank you for the opportunity to work at La Poste ! www.xebia.fr | http://blog.xebia.fr | #CassandraEU Telephone : 33 (0)1 53 89 99 99 | email : info@xebia.fr | 156 bd Haussmann - 75008 Paris 23

×