Tungsten University: Unleashing the Power of Tungsten Connectors

1,113 views

Published on

Continuent Tungsten clusters use the Tungsten Connector to ensure your applications transparently connect to the master. This enables failover and seamless switching of masters for maintenance. However, you can do far more. Tungsten Connector allows you to make better use of hardware by load balancing SQL traffic to slaves. There is also a wealth of configuration settings to help Tungsten Connector manage connections efficiently. Learn standard deployment patterns, how to create users, control load balancing, how to distribute reads across local and remote sites, and other configuration tricks. We also provide advice about how to adapt your applications to use load balancing more efficiently.

Course Topics
- Deployment options and techniques
- Configuring users with regard to data services
- Application configuration samples
- Read/write splitting options and demos
- Load balancing strategies
- Optimization of connection and request speed
- Understanding and fixing connectivity issues

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,113
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Tungsten University: Unleashing the Power of Tungsten Connectors

  1. 1. Tungsten University: Unleashing the Power of Tungsten Connectors Gilles Rayrat, Director of Operations/France©Continuent 2013
  2. 2. What is Tungsten Connector? Native protocol App COM_QUERY COM_INIT_DB COM_DROP_DB Connector©Continuent 2013 2
  3. 3. A Key Tungsten Component • Provide access to the master • Handle database failures • Can access slaves for reads©Continuent 2013 3
  4. 4. Deployments©Continuent 2013 4
  5. 5. Deployment 1: app servers App Server App Server App Server App Server App Server + Connector + Connector + Connector + Connector + Connector©Continuent 2013 5
  6. 6. Deployment 2: database servers App Server App Server App Server App Server App Server App Server ... Software Load Balancer©Continuent 2013 6
  7. 7. Deployment 3: dedicated hosts App Server App Server App Server App Server App Server App Server ... Hardware Load Balancer ...©Continuent 2013 7
  8. 8. Deployment best practice Install with port 3306! tools/tpm con!gure <data service name> <options> --connector-listen-port=3306©Continuent 2013 8
  9. 9. Closer view • Performance • Failure handling©Continuent 2013 9
  10. 10. Packet Streaming • Fast operations, Low overhead • Full transparency Protocol packet COM_QUERY select * from t App Connector Protocol packet OK ResultSet Rows:1©Continuent 2013 10
  11. 11. Closer view • Performance • Failure handling©Continuent 2013 11
  12. 12. Connector-Manager link App Logic App Logic Tungsten Connector Tungsten Connector Monitoring and control Monitoring and control Manager Manager Manager Replicator Replicator Replicator Slave Master Slave©Continuent 2013 12
  13. 13. Node Failure “Pause” incoming connection requests + Planned switch: Unplanned Failover: wait for disconnect break connections + Transparent retry (autocommit tx only)©Continuent 2013 13
  14. 14. Demo? u1 u3 u2 u4 europe asia world©Continuent 2013 14
  15. 15. Installation • tools/tpm con!gure <data service name> <options> --dataservice-connectors=node1,node2,... • --connector-listen-port --connector-user --connector-password --connector-smartscale=true • tools/tpm help con!gure©Continuent 2013 15
  16. 16. Specifying Users • --connector-user=user1 • additional users in tungsten-connector/conf/user.map©Continuent 2013 16
  17. 17. user map <user> <password> <data service> [<preferred site>] tungsten_testing private world europe myuser p4$$ asia alice - othersvc No need to restart©Continuent 2013 17
  18. 18. Connection Protocol version #, ..., salt App Database, user, Salted password©Continuent 2013 18
  19. 19. A Man in the Middle Connector App ?©Continuent 2013 19
  20. 20. Clear text passwords • Workaround: @script /opt/continuent/share/gen_user_map.sh • output identical to regular user.map • Can be any script: SQL requests, encrypting, etc. • Accepts parameters©Continuent 2013 20
  21. 21. Application con!guration©Continuent 2013 21
  22. 22. Application con!guration - PHP <?php $host = “u1”;  $port = 9999; $username = “tungsten_testing”; $password = “secret_private”; $dbname = “myapp"; $connection = mysqli_connect($host, $username, $password, $dbname, $port); ......... More application logic here ......... ?>©Continuent 2013 22
  23. 23. Application con!guration - Java • Hibernate hibernate.connection.url=jdbc:mysql://u1:9999/mydb • JBoss <connection-url>jdbc:mysql://u1:9999/database</ connection-url> • JDBC jdbc:mysql://u1:9999/dbname©Continuent 2013 23
  24. 24. Application con!guration - Ruby on Rails prod:   adapter: mysql2   encoding: utf8   database: my_db_name   username: tungsten_testing   password: private   host: u1   port: 9999©Continuent 2013 24
  25. 25. Read/write splitting • Automatic • Application Controlled©Continuent 2013 25
  26. 26. Automatic R/W splitting • No application changes • Only outside transaction boundaries • 2 variants: • Smart Scale • @direct connections©Continuent 2013 26
  27. 27. Automatic R/W splitting - smartScale • AKA ‘session consistency’ QoS • Ability to see session’s writes©Continuent 2013 27
  28. 28. SmartScale Master Transaction DBMS History Log write Session x App Session y ... Slave replay Connector position Slave DBMS©Continuent 2013 28
  29. 29. SmartScale Master Transaction DBMS History Log read Session x App Connector Slave replay position Slave DBMS©Continuent 2013 29
  30. 30. SmartScale Master Transaction DBMS History Log read Session x App Connector Slave replay position Slave DBMS©Continuent 2013 30
  31. 31. SmartScale • Enabling: tpm configure <data service name> <other options> --connector-smartscale=true --connector-smartscale-sessionid= DATABASE | USER | CONNECTION | PROVIDED_IN_DBNAME©Continuent 2013 31
  32. 32. SmartScale • Choose you sessionId: • PROVIDED_IN_DBNAME (++) => set dbname to ”mydb?sessionId=12345” • CONNECTION (+) • USER (-) • DATABASE (--)©Continuent 2013 32
  33. 33. Demo?©Continuent 2013 33
  34. 34. SmartScale Limitations: • single connector instance • select function_that_writes(); • ephemeral SQL objects©Continuent 2013 34
  35. 35. SmartScale Trade-o": • Can read outdated data from other sessions • Poor e!ciency in write intensive environments©Continuent 2013 35
  36. 36. Automatic R/W splitting - directReads • Blind R/W splitting • Fast • Similar limitations: • ephemeral SQL objects • select function_that_writes(); • Reads potentially outdated data©Continuent 2013 36
  37. 37. DirectReads • Enabling tpm configure <ds> <opts> --connector-rwsplitting=true • Other users in user.map @direct user2 @direct user3 • Can be backed by a c3p0 pool©Continuent 2013 37
  38. 38. Read/write splitting • Automatic • Application Controlled©Continuent 2013 38
  39. 39. Application-driven R/W splitting • More e#cient... • ...but potentially dangerous • 3 possibilities: • SQL comments • QoS in database name • @hostoption©Continuent 2013 39
  40. 40. Selective R/W Splitting • Must enable directReads tpm update ... --connector-rwsplitting=true --property=selective.rwsplitting=true • Embedded SQL comment: !!! mysql -u... -c /* TUNGSTEN_URL_PROPERTY=qos=RO_RELAXED */select @@hostname;©Continuent 2013 40
  41. 41. Demo?©Continuent 2013 41
  42. 42. QoS at connection time • No connector con!guration change • connect to “mydb@qos=RO_RELAXED”©Continuent 2013 42
  43. 43. Demo?©Continuent 2013 43
  44. 44. Host-based routing • /etc/hosts 127.0.0.1 master.localhost 127.0.0.2 slave.localhost • tpm configure <data service name> <other options> --connector-rw-addresses=master.localhost --connector-ro-addresses=slave.localhost©Continuent 2013 44
  45. 45. Demo?©Continuent 2013 45
  46. 46. SOR (multi site) • Getting a local slave <user> <password> <data service> [<preferred site>] tungsten_testing private world europe©Continuent 2013 46
  47. 47. Demo?©Continuent 2013 47
  48. 48. Performance • Pool for DirectReads tpm configure <ds> <opts> --connector-rwsplitting=true --property=directReadsUsePool=true • JDBC driver--property=jdbc.driver.options=cacheServerCon!guration=true&characterSetResults=UTF8 https://docs.continuent.com/wiki/display/ TEDOC/Improving+Connection+Speed©Continuent 2013 48
  49. 49. Getting connector information • “tungsten connection status” for last request mysql> tungsten connection status; +---------------------------------------------------------------+ | message | +---------------------------------------------------------------+ | internal(OPEN) DIRECT TO u1@default(master:ONLINE) STATUS(OK) | +---------------------------------------------------------------+ 1 row in set (0.01 sec) • “tungsten show processlist” for real client addresses mysql> tungsten show processlist; +------------+------+----------+-----------+----------+---------+------+-------+------+ | DataSource | Id | User | Host | db | Command | Time | State | Info | +------------+------+----------+-----------+----------+---------+------+-------+------+ | u1 | 1342 | tungsten | mac:64477 | tungsten | Sleep | 20 | | NULL | +------------+------+----------+-----------+----------+---------+------+-------+------+ 1 row in set (0.13 sec)©Continuent 2013 49
  50. 50. Troubleshooting • tungsten-connector/log/connector.log • Lots of connections in TIME_WAIT state • Too many open !les • OutOfMemory error • New connections hanging©Continuent 2013 50
  51. 51. Tungsten University Sessions • Manage multi-master or fan-in replication topologies - March 7th & 12th • Zero-downtime maintenance and schema operations - March 21st & 26th • Geographically distributed MySQL clusters - April 11th & 16th • Replicate between MySQL and Oracle - May 2nd & 7th©Continuent 2013 51
  52. 52. 560 S. Winchester Blvd., Suite 500 Our Blogs:San Jose, CA 95128 http://scale-out-blog.blogspot.comTel +1 (866) 998-3642 http://datacharmer.org/blogFax +1 (408) 668-1009 http://www.continuent.com/news/blogse-mail: sales@continuent.com Continuent Web Page: http://www.continuent.com Tungsten Replicator 2.0: http://code.google.com/p/tungsten-replicator©Continuent 2013

×