Weitere ähnliche Inhalte Ähnlich wie Jee技术在移动互联网中的应用 Ähnlich wie Jee技术在移动互联网中的应用 (20) Jee技术在移动互联网中的应用1. JEE
--
njthnet#gmail.com
2010.8
2. About Me
• Name@H.E./
• Jbos@JEE Architect
• Title@JEvangelist
• Life@NanJing
• Hobby@Photography
• http://www.javabloger.com
13. Internet
User
3G
GSM WiFi
Mobile Internet
Mobile Computing Service
Computing Server Provide
User
15. --
•
–
• VIPS
•
•
• JS
•
•
19. – IM
• IM
–
• XML XML XPATH DOM
• http
• XMMP
• Linux
•
21. – Sync
• Sync
–
• WBXML
• XML
• SyncML
• Sync4J Merge
• SMSC Push
•
23. – LBS
• LBS
–
• (Geographic Markup Language)
• WiFi/GSM/CDMA
• XML JSON
•
• Http
24. • Android
• EC2
• Java
• Linux
26. • Web Ngixn Apache HA-Proxy
• App Server GlassFish Jboss Jetty
• OpenMQ JbossMQ
• MySQL
• Memcached OSCache
• NFS MogileFs Gluster
• Nagois
• Jamse
• HA-Proxy LVS
• Heartbeat
29. JEE
• JEE
• Servlet
• XML / /
• JDBC CRUD
• JMS /
• JavaMail
• JTA
31. Web Portal Client
Android/iPhone/Nokia
Web Device
Portal XML/XSL/WBXML
HTML/CSS/Ajax
GSM
wan
Web
Dispatch Router
Adapter
Adapter
Adapter
DB
32. Web Client
Web Layer
Dispatch Layer
Adapter Layer
Data Access Layer
33. Sync
SP
Push
Device SMSC
Sync
Synced
Web
Load JMS
Balance
DB Scheduled
Load Accounts
34. Sync
Web Layer
Business Layer
Data Access Layer
Internal Communication Layer
35. PushMail
Push GSM
Gateway
Yahoo
Device Agent
Gmail SP
Agent
Mail
Hot Mail Server
Agent
Web
JMS
FileSystem
DB
Task Factory
36. PushMail
Web Interface
Admin GUI
Agent Layer &
CRM System
Notification Layer
Data Access Layer
File
System
Internal Communication Layer
37. IM
Device
Monitor SP
Cache
Asynchronous
Interval Http
Long Connection
Web
JMS
Load
Balance
DB
Trans
Check Status
38. IM
Web Layer
Internal Communication Layer
Cache
Monitor Factory
Agent Trans Layer
Data Access Layer
39. LBS
LBS
GSM Latitude
Service
CellID Gateway
Device
Agent
Web JMS
LBS
Cartographic
DB Business
Manager
Database
40. LBS
Web Layer
Internal Communication Layer
Cartographic
LBS Business Manager
Database
LBS Agent Layer
Data Access Layer
43. (Why)
Load Balancing
Failure over High Availability
44. 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
45. Web App Part1
App1
Apache Session
App2
47. Web App Part2
Work App1
Apache
Session
Heartbeat
Apache App2
Standby
48. 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
49. Web App Part3
Session Stick
Work App1
Session Stick
Apache
App2
Heartbeat
Session Stick
Apache App3
Standby
50. 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
51. Web App Part4
Session
Work TCP Mode App1
HAProxy
TCP Mode
Cache
App2
Heartbeat TCP Mode
HAProxy App3
Standby
Share Nothing Architecture --RasmusLerdor(PHP )
, .
52. Web App Part4 II
Work App Session
Tcp Mode
HAProxy Tcp Mode
Cache Cache
App2
Heartbeat Tcp Mode
replication
HAProxy App3
Standby
53. American Canada
slow
China
very slow
How to Handle?! very fast
54. Web App Part5
CDN
Service
dispatch
dispatch
App
App
dispatch App
App
App Canada
App
App
China App
App
USA
55. • 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
56. Part1
App
Replication
DB DB
Master Slave
58. Part2
App
R/W R/W
Work Replication Standby
DB DB
Master Master
Switch
59. 35% Write 65%Read
DB
DB
write
Read
How to Handle?!
60. Part3
App
MySQL-Proxy
W R
Slave
DB
DB Replication
DB
DB
DB
Master
61. 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?!
62. Part4
App
MySQL JDBC round robin
DB
DB DB
MySQL Cluster
MySQL Cluster
63. MySQL Cluster No Support long
columns
MySQL Support Tab
Long columns
NDB Engine
How to Handle?!
64. 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
65. • HashMap 1:0
• OScache 1:0
• OScache Cluster N:N
• Memcached 1:0
• Memcached +Magent 2:N
• Memcached +repcached N:N
67. How to share in cluster environment
App
App
Cache
Everything in local
Local Server
68. part2
Total
66M
12M 22M 32M
App App App
App
OSCache App
OSCache App
OSCache
Server1 Server2 Server3
Replication Replication
69. 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
70. part3
12M 22M 32M
App App
App
Server1 Server3
Server2
Server2
Total
Memcached 32M
72. part4
double
Memcached
App
Memcached
Agent
Server1
Memcached
double
73. If Memcached Agent break!
Memcached Agent Single Point Issue
Memcached Memcached Restore Issue
Agent
How to Handle?! How to replication?!
74. part5
Memcached Memcached
Group1
+ +
Repcached Repcached
Replication
App
Server1-3
Group2
Memcached Memcached
+ +
Repcached Repcached
Replication
75. JMS
• Jboss JMS 1:0
• OpenMQ 1:0
• OpenMQ Cluster 2:N
• OpenMQ Cluster N:N
76. JMS Part1
Topic
Consumer
Producer JMS
Queue
Consumer
77. If JMS Server break!
If JMS Server Overload!
JMS
How to Handle?!
78. JMS Part2
Topic
work
Consumer
Random
Producer
JMS
Queue
Ra
work Consumer
nd
om
Takeover Queue
JMS
Consumer
Topic
Consumer
79. • Local Log4j Single 1:0
• Local Package Output 1:0
• Log4j to NOSQL N:1
• Log4j Server to Client N:N
80. Part1
App App
Server Server
Log4j Log4j
Log View
82. Part2
App
GUI
Server Tools
Log4j
NOSQL
App
Server
Log4j
83. “I Need Track Business Status
and Alarm It !”
How to Handle?!
Customer
84. Part3
App GUI
Tools
Server
Log4j Log4j
Server
NOSQL
App
Server Alarm
Log Server
Filter
Log4j
Server
86. Task Part1
Task
Server
worker
Accounts
(Threads)
87. 100W Accounts
in time have 1W Thread! ?
We need a God Server ?!
How to Handle?!
88. Task Part2
Work Standby
3K Jobs HeartBeat
Task Task
EJB
Server
(Cluster)
1K 1K
1K
Jobs Jobs
Jobs
89. In Progress a Job Server Down!
Jobs Unfinished
Server Job
How to Handle?!
90. Task Part3
Standby
Work
3K Jobs Task
Task
EJB
Server Job
Unfinished Job
Tracker
1K
1K
1K
Jobs
Jobs
Jobs Watch
91. Task Part4
• Yahoo Zookeeper
•
•
93. • Linux OS
• JVM
• Web Server & Proxy
• App Server
• Databases & SQL
• JMS
• Distributed Transaction
• Code & Business Logic