Jee技术在移动互联网中的应用

1,502 views

Published on

移动计算

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

  • Be the first to like this

No Downloads
Views
Total views
1,502
On SlideShare
0
From Embeds
0
Number of Embeds
583
Actions
Shares
0
Downloads
40
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Jee技术在移动互联网中的应用

  1. 1. JEE -- njthnet#gmail.com 2010.8
  2. 2. About Me • Name@H.E./ • Jbos@JEE Architect • Title@JEvangelist • Life@NanJing • Hobby@Photography • http://www.javabloger.com
  3. 3. • • • • •
  4. 4. Overview
  5. 5. 2006 IM LBS
  6. 6. PC
  7. 7. /Mp3 Wap IC
  8. 8. Story
  9. 9. 2010 Construction
  10. 10. • • PC •
  11. 11. • • • • • • •
  12. 12. Mobile Computing IM MSOffice Web Page Multimedia Map PushMail Info etc …
  13. 13. Internet User 3G GSM WiFi Mobile Internet Mobile Computing Service Computing Server Provide User
  14. 14. -- •
  15. 15. -- • – • VIPS • • • JS • •
  16. 16. - pushmail • Push Mail
  17. 17. -- pushmail • – • XML • Push • • J2EE •
  18. 18. – IM • IM
  19. 19. – IM • IM – • XML XML XPATH DOM • http • XMMP • Linux •
  20. 20. - Sync •Sync
  21. 21. – Sync • Sync – • WBXML • XML • SyncML • Sync4J Merge • SMSC Push •
  22. 22. - LBS • Location Based Services
  23. 23. – LBS • LBS – • (Geographic Markup Language) • WiFi/GSM/CDMA • XML JSON • • Http
  24. 24. • Android • EC2 • Java • Linux
  25. 25. • Web Ngixn Apache HA-Proxy • App Server GlassFish Jboss Jetty • OpenMQ JbossMQ • MySQL • Memcached OSCache • NFS MogileFs Gluster • Nagois • Jamse • HA-Proxy LVS • Heartbeat
  26. 26. Java
  27. 27. Java • Java • ibatis DAL • ImageMagick • SyncML • Xstream XML • XMPP XML • Apache POI • Log4J
  28. 28. JEE • JEE • Servlet • XML / / • JDBC CRUD • JMS / • JavaMail • JTA
  29. 29. Architecture
  30. 30. Web Portal Client Android/iPhone/Nokia Web Device Portal XML/XSL/WBXML HTML/CSS/Ajax GSM wan Web Dispatch Router Adapter Adapter Adapter DB
  31. 31. Web Client Web Layer Dispatch Layer Adapter Layer Data Access Layer
  32. 32. Sync SP Push Device SMSC Sync Synced Web Load JMS Balance DB Scheduled Load Accounts
  33. 33. Sync Web Layer Business Layer Data Access Layer Internal Communication Layer
  34. 34. PushMail Push GSM Gateway Yahoo Device Agent Gmail SP Agent Mail Hot Mail Server Agent Web JMS FileSystem DB Task Factory
  35. 35. PushMail Web Interface Admin GUI Agent Layer & CRM System Notification Layer Data Access Layer File System Internal Communication Layer
  36. 36. IM Device Monitor SP Cache Asynchronous Interval Http Long Connection Web JMS Load Balance DB Trans Check Status
  37. 37. IM Web Layer Internal Communication Layer Cache Monitor Factory Agent Trans Layer Data Access Layer
  38. 38. LBS LBS GSM Latitude Service CellID Gateway Device Agent Web JMS LBS Cartographic DB Business Manager Database
  39. 39. LBS Web Layer Internal Communication Layer Cartographic LBS Business Manager Database LBS Agent Layer Data Access Layer
  40. 40. “ ”
  41. 41. Scale-out
  42. 42. (Why) Load Balancing Failure over High Availability
  43. 43. Web App • App single 1:0 • Apache to App 1:2 • Apache to App 2:2 • HAProxy to App N:N • HAProxy+Cache to App N:N
  44. 44. Web App Part1 App1 Apache Session App2
  45. 45. If Apache Down! Everything Down!! Apache How to Handle?!
  46. 46. Web App Part2 Work App1 Apache Session Heartbeat Apache App2 Standby
  47. 47. If Many Nodes! App1 App1 App1 App1 App1 App1 App1 Session Replication? App1 App1 App1 Too bad! App1 App1 App1 App1 App1 App1 App1 App1 How to Handle?! App
  48. 48. Web App Part3 Session Stick Work App1 Session Stick Apache App2 Heartbeat Session Stick Apache App3 Standby
  49. 49. 2 Issues Reasons1 Fast Slow HTTPS HTTP UDP TCP Http Application Layer Reasons2 O One Account to One Session, S Transport Layer Tcp One Session to One Server. I Network Physical Layer
  50. 50. Web App Part4 Session Work TCP Mode App1 HAProxy TCP Mode Cache App2 Heartbeat TCP Mode HAProxy App3 Standby Share Nothing Architecture --RasmusLerdor(PHP ) , .
  51. 51. Web App Part4 II Work App Session Tcp Mode HAProxy Tcp Mode Cache Cache App2 Heartbeat Tcp Mode replication HAProxy App3 Standby
  52. 52. American Canada slow China very slow How to Handle?! very fast
  53. 53. Web App Part5 CDN Service dispatch dispatch App App dispatch App App App Canada App App China App App USA
  54. 54. • MySQL Master single 1:0 • MySQL Master to Slave 1:N • MySQL Master to Master 1:1 • MySQL Write And Read 1:N • MySQL Sharding N:N
  55. 55. Part1 App Replication DB DB Master Slave
  56. 56. If MySQL Master break! DB Master How to Handle?! How to replication?!
  57. 57. Part2 App R/W R/W Work Replication Standby DB DB Master Master Switch
  58. 58. 35% Write 65%Read DB DB write Read How to Handle?!
  59. 59. Part3 App MySQL-Proxy W R Slave DB DB Replication DB DB DB Master
  60. 60. Write I/O bottleneck Master to Master Not Load Balance Database Overload JDBC Client JDBC Client JDBC Client JDBC Client JDBC DB Client JDBC Client How to Handle?!
  61. 61. Part4 App MySQL JDBC round robin DB DB DB MySQL Cluster MySQL Cluster
  62. 62. MySQL Cluster No Support long columns MySQL Support Tab Long columns NDB Engine How to Handle?!
  63. 63. Part5 App user_id=1001 Data db_cluster=1 Router SELECT * FROM users WHERE User_id=1001 1-2W Users 3w-N DB SELECT * FROM Search Users users WHERE DB username=‘tom’ DB DB Index DB DB DB DB_Cluster1 MySQL Master To Master DB_Cluster2 MySQL Master To Master
  64. 64. • HashMap 1:0 • OScache 1:0 • OScache Cluster N:N • Memcached 1:0 • Memcached +Magent 2:N • Memcached +repcached N:N
  65. 65. part1 App App Cache Local Server
  66. 66. How to share in cluster environment App App Cache Everything in local Local Server
  67. 67. part2 Total 66M 12M 22M 32M App App App App OSCache App OSCache App OSCache Server1 Server2 Server3 Replication Replication
  68. 68. If Many Nodes! App App App App OSCache App App OSCache App App OSCache App Server1 App OSCache App Server1 App OSCache App Server1 App OSCache App Server1 App OSCache App Server1 App OSCache App Server1 App OSCache App Server1 App OSCache App Server1 App OSCache App Server1 App OSCache App Server1 App OSCache App Server1 App OSCache App How to Handle?! Server1 App OSCache App Server1 App OSCache Server1 App OSCache Server1 App OSCache Server1 Server1 ServerN
  69. 69. part3 12M 22M 32M App App App Server1 Server3 Server2 Server2 Total Memcached 32M
  70. 70. If Memcached Down! Memcached How to Handle?!
  71. 71. part4 double Memcached App Memcached Agent Server1 Memcached double
  72. 72. If Memcached Agent break! Memcached Agent Single Point Issue Memcached Memcached Restore Issue Agent How to Handle?! How to replication?!
  73. 73. part5 Memcached Memcached Group1 + + Repcached Repcached Replication App Server1-3 Group2 Memcached Memcached + + Repcached Repcached Replication
  74. 74. JMS • Jboss JMS 1:0 • OpenMQ 1:0 • OpenMQ Cluster 2:N • OpenMQ Cluster N:N
  75. 75. JMS Part1 Topic Consumer Producer JMS Queue Consumer
  76. 76. If JMS Server break! If JMS Server Overload! JMS How to Handle?!
  77. 77. JMS Part2 Topic work Consumer Random Producer JMS Queue Ra work Consumer nd om Takeover Queue JMS Consumer Topic Consumer
  78. 78. • Local Log4j Single 1:0 • Local Package Output 1:0 • Log4j to NOSQL N:1 • Log4j Server to Client N:N
  79. 79. Part1 App App Server Server Log4j Log4j Log View
  80. 80. Too Many Servers Too Many Logs How to Handle?! Developer
  81. 81. Part2 App GUI Server Tools Log4j NOSQL App Server Log4j
  82. 82. “I Need Track Business Status and Alarm It !” How to Handle?! Customer
  83. 83. Part3 App GUI Tools Server Log4j Log4j Server NOSQL App Server Alarm Log Server Filter Log4j Server
  84. 84. Task • Jboss JMS 1:0 • OpenMQ 1:0 • OpenMQ Cluster 1:N
  85. 85. Task Part1 Task Server worker Accounts (Threads)
  86. 86. 100W Accounts in time have 1W Thread! ? We need a God Server ?! How to Handle?!
  87. 87. Task Part2 Work Standby 3K Jobs HeartBeat Task Task EJB Server (Cluster) 1K 1K 1K Jobs Jobs Jobs
  88. 88. In Progress a Job Server Down! Jobs Unfinished Server Job How to Handle?!
  89. 89. Task Part3 Standby Work 3K Jobs Task Task EJB Server Job Unfinished Job Tracker 1K 1K 1K Jobs Jobs Jobs Watch
  90. 90. Task Part4 • Yahoo Zookeeper • •
  91. 91. Share
  92. 92. • Linux OS • JVM • Web Server & Proxy • App Server • Databases & SQL • JMS • Distributed Transaction • Code & Business Logic
  93. 93. Questions to... njthnet@gmail.com
  94. 94. www.javabloger.com

×