3. About Me
• Hirotomo Ōi
• Chief Architect of infrastructure of web.
• And “engekilife.com” tech guy.
• And...planning/developing new website.
4. About MTL
• MTL(Media Technology Lab.) is an
applied study institute to promote future
media communication, and to seek for a
sympathetic world for all of us.
• One of our focus:
Develop prototype web sites, and verify
responses and feedbacks through beta
releases.
15. Virtualize servers
• Two or more servers
can be running on one
Web,
hardware. App DB cache
(memory-
(CPU- (IO-bound)
bound)
• Generally, different bound)
resources are put
together is good
efficiency.
16. virtualize webservers
• We are virtualizing
web+app tier.
• Generally web site A
(ruby)
site B
(php)
site C
(perl)
apps are CPU-
bound.
• RoR apps need
memory.
17. How many VMs?
• Hardware
• 16GB memory
• 2x Quad Core Xeon
• VM Spec
• 1GB memory
• 10GB disk space
• 8 CPU cores
available
18. How many VMs?
• Hardware
• 16GB memory
• 2x Quad Core Xeon
• VM Spec 13
• 1GB memory VMs / Hard
• 10GB disk space
• 8 CPU cores
available
22. DB Tuning
• Developers often forget DB tuning when
launch the site.
• Developers use ActiveRecord, not
connect DB directly.
23. DB Tuning
• Developers often forget DB tuning when
launch the site.
• Developers use ActiveRecord, not
connect DB directly.
DO NOT FORGET DATABASE!!
29. 1) Know Slow Query
mysql> SELECT * FROM `rubykaigi_demo`
WHERE `type` = 'PlayguideTicketInfoShow'
and `bukken_id` = 435;
+-------+-------------------------+-----------+
| id | type | bukken_id |
+-------+-------------------------+-----------+
| 13139 | PlayguideTicketInfoShow | 435 |
+-------+-------------------------+-----------+
1 row in set (0.01 sec)
30. 2) EXPLAIN
mysql> EXPLAIN SELECT * FROM
`rubykaigi_demo` WHERE `type` =
'PlayguideTicketInfoShow' and `bukken_id`
= 435G
id: 1
select_type: SIMPLE
table: rubykaigi_demo
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 2299
Extra: Using where
31. 2) EXPLAIN
mysql> EXPLAIN SELECT * FROM
`rubykaigi_demo` WHERE `type` =
'PlayguideTicketInfoShow' and `bukken_id`
= 435G
id: 1
select_type: SIMPLE
table: rubykaigi_demo
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL Not Using Index
rows: 2299
Extra: Using where
33. 4) RESULT
mysql> EXPLAIN SELECT * FROM
`rubykaigi_demo` WHERE `type` =
'PlayguideTicketInfoShow' and `bukken_id`
= 435G
id: 1
select_type: SIMPLE
table: rubykaigi_demo
type: ref
possible_keys: type
key: type
key_len: 773
ref: const,const
rows: 1
Extra: Using where; Using index
34. 4) RESULT
mysql> EXPLAIN SELECT * FROM
`rubykaigi_demo` WHERE `type` =
'PlayguideTicketInfoShow' and `bukken_id`
= 435G
id: 1
select_type: SIMPLE
table: rubykaigi_demo
type: ref
possible_keys: type
key: type
key_len: 773
ref: const,const Using Index
rows: 1
Extra: Using where; Using index
37. Restart Mongrel
• Restart periodically for fix memory leak
of Mongrel processes.
• Using swap, not only the VM but all
VMs on same HW are slow down...