Profile
• Github: @maxmellon
• Twitter: @maxmellon_9039
• Start working second year at the recruit-tech
• Yosuke Furukawa’s subordinate
*BN/FXCJF
'SPOUFOE&OHJOFFS
✨
✨
Slide 4
Slide 4 text
Let me introduce one
My favorite food
Slide 5
Slide 5 text
Udon
͏ͲΜ
Slide 6
Slide 6 text
:VVVVN
Slide 7
Slide 7 text
Let’s talk about main subject
Slide 8
Slide 8 text
What am I doing in R-tech
• Develop “AirSHIFT”
• Develop new features
• Improve performance
• Performance Hackson in frontend
• In other products than AirSHIFT
Slide 9
Slide 9 text
What is the “AirSHIFT” ?
Slide 10
Slide 10 text
"EKVTUNFOU
4IJGUT
AirSHIFT is web service for store managers
of part time staffs
※ “Store Manager” manages all schedule
of part time job in Japanese
$SFBUFXPSL
4DIFEVMF
-JTUVQTIJGUT
$PMMFDUTIJGUT
GSPNQBSUT
3FNJOE
1SJOUPVU
3FRVFTU
XPSL
Slide 11
Slide 11 text
So rich UI as Desktop Application
Slide 12
Slide 12 text
Architecture
Slide 13
Slide 13 text
BFF
(express)
Client API
Isomorphic
Session Data
Notification
(socket.io)
Redis
FCM wrapper
(React/Redux)
Fetchr
CSR SSR
DB
Push
Notification
WebSocket
OAuth
CellPhone
Application
For Part time worker
Slide 14
Slide 14 text
͜Ε·ͰͷύϑΥʔϚϯεվળ
Performance improvements so far
Slide 15
Slide 15 text
̎ͭͷΞϓϩʔνͰվળ
Improved performance with two approaches
https://speakerdeck.com/maxmellon/reactzhi-spa-niokeru-pahuomansutiyuningu
࠶ϨϯμϦϯάͷ࠷దԽ
0QUJNJ[BUJPOSFSFOEFSJOH
େ͖ͳςʔϒϧͷ7JSUVBMJ[FEԽ
7JSUVBMJ[FEMBSHFTDBMFUBCMFDPNQPOFOU
Nodefest’ 18ɺHTML5 Conf Ͱհ
Introduced Nodefest’ 18 and HTML5 Conf
Slide 16
Slide 16 text
https://speakerdeck.com/maxmellon/reactzhi-spa-niokeru-pahuomansutiyuningu
࠶ϨϯμϦϯάͷ࠷దԽ
0QUJNJ[BUJPOSFSFOEFSJOH
େ͖ͳςʔϒϧͷ7JSUVBMJ[FEԽ
7JSUVBMJ[FEMBSHFTDBMFUBCMFDPNQPOFOU
Nodefest’ 18ɺHTML5 Conf Ͱհ
Introduced Nodefest’ 18 and HTML5 Conf
ৄࡉ͜ͷεϥΠυʹॻ͍ͯ͋Γ·͢
Details are in these slides
https://speakerdeck.com/maxmellon/reactzhi-spa-niokeru-pahuomansutiyuningu
Slide 17
Slide 17 text
Before
13,529ms
After
3,612ms
CPU x4 slow
Fast 3G
Improvement
վળ
374%
Slide 18
Slide 18 text
͔͠͠…
but…
Slide 19
Slide 19 text
13,529ms
3,612ms
3.6ඵ͍ͬͯͷʁ
Is 3.6 second so fast?
Slide 20
Slide 20 text
PGVTFSTXJMMMFBWFJGQBHFMPBEJOH
UJNFJTMPOHFSUIBOTFDPOET
News Lab Japanese AMP Office Hour: Introduction to AMP with Duncan Wright, Strategic Partner Manager ΑΓ
https://www.youtube.com/watch?time_continue=150&v=3N6yDLP1WUIa
Slide 21
Slide 21 text
͞ΒͳΔվળ͕ඞཁ
Further performance improvement is needed
Slide 22
Slide 22 text
ࠓ͞ΒͳΔվળʹ͍ͭͯհ͠·͢
Today I’ll introduce further improvement
Slide 23
Slide 23 text
ϘτϧωοΫͷௐࠪ
Investigation of bottlenecks
Slide 24
Slide 24 text
ௐࠪ݅
Research condition
• /sft/monthlyshift/201701
→ /sft/monthlyshift/201702 ͷભҠ
• ը໘αΠζ 1440 x 900 (ϝΠϯλʔήοτ)
transition
Display size Main target
Slide 25
Slide 25 text
No content
Slide 26
Slide 26 text
ؔͷ࣮ߦ͚ͩͰ110ms
110ms with function execution only
ϘτϧωοΫ ͦͷ1
Bottleneck 1
Slide 27
Slide 27 text
Կͯ͠Δͷ͔ʁ
What is actually happening?
Slide 28
Slide 28 text
No content
Slide 29
Slide 29 text
No content
Slide 30
Slide 30 text
No content
Slide 31
Slide 31 text
No content
Slide 32
Slide 32 text
No content
Slide 33
Slide 33 text
No content
Slide 34
Slide 34 text
େྔͷmomentͷΠϯελϯεΛੜ
Create many instances of moment
Slide 35
Slide 35 text
ϘτϧωοΫ ͦͷ2
Bottleneck 2
ͯ͢ಉ͡ίϯϙʔωϯτ
All same components
ΞΫγϣϯ͕dispatch͞ΕΔͱ࠶ϨϯμϦϯά͕ى͖Δ
Re-render happens with each action dispatch
Slide 36
Slide 36 text
ͳͥ࠶ϨϯμϦϯά͕ൃੜʁ
Why re-render?
Slide 37
Slide 37 text
reselectΈΜͳͬͯΔʁ
Reselect ͕ ຖճҧ͏ Object Λฦ٫͍ͯͨ͠
reselect was returning different object each time
Slide 38
Slide 38 text
No content
Slide 39
Slide 39 text
ଞʹ͍͔ͭ͘ϘτϧωοΫ͕͋ͬͨ
There were more bottlenecks
Slide 40
Slide 40 text
1ͭ1ͭվળͯ͠Ϩϙʔτʹ·ͱΊͨ
All of them were resolved and summarized in reports
Slide 41
Slide 41 text
Moment Λେྔʹੜ͍ͯ͠Δ
• ಉ͡ͷ࠶ੜ͍ͯͨ͠ͷͰͻͱ·ͣmemoize
• ͯ͢UnixTimeʹΑΔܭࢉʹॻ͖͍ͨ͠
ˠ ͨͩɼ͓ۚपΓσάϨͬͨͱ͖ͷϦεΫ͕େ͖͘அ೦
Hope to re-implementation by unix time.
Memoized instance for a while
Issue 1: many moment instances
Slide 42
Slide 42 text
Reselect ͕ຖճҧ͏ObjectΛੜ͍ͯ͠Δ
• Reselect ͷΛνʔϜͰ࠶֬ೝ
• ΞϯνύλʔϯΛհͯ͠࠶ൃࢭ
Issue 2: reselect returning different object each time
Introduced how to use reselect and anti-patterns to team
Slide 43
Slide 43 text
ͦͷ݁Ռ
Results
Slide 44
Slide 44 text
50%ͷϢʔβʔ1.5ඵҎʹ
Ӿཡ͢Δ͜ͱ͕Ͱ͖ΔΑ͏ʹ
⚪ ⚪
⚪ ⚪ ⚪ ⚪ ⚪
⚪ ⚪ ⚪ ⚪ ⚪
50% of users can load the page within 1.5sec
Slide 45
Slide 45 text
75%ͷϢʔβʔ3.0ඵҎ
⚪ ⚪
⚪ ⚪ ⚪ ⚪ ⚪
75% of users can load within 3.0 sec
Slide 46
Slide 46 text
Γ25%3ඵͰඳըग़དྷ͍ͯͳ͍
25% of users take longer than 3 sec
Slide 47
Slide 47 text
͜ͷ40%͕ͷՄೳੑ
୯७ʹͯΊΔͱ
40% of them might leave
Slide 48
Slide 48 text
ࠓɼ͜ΕΛղܾ͢ΔͨΊͷࢪࡦΛݕ౼͍ͯ͠Δ
We are examining to solve this
Slide 49
Slide 49 text
͜ΕΒͷϢʔβʔͷಛ
• ଞͷϢʔβʔΑΓCPUͷੑೳ͕͍ʢͱਪଌͰ͖Δʣ
CPUΛΘͳ͍Ξϓϩʔν͕ඞཁ
The characteristic of these users
have lower CPU spec than other users
Will need approach that DON'T use CPU
Slide 50
Slide 50 text
Prefetch
Slide 51
Slide 51 text
PrefetchʹΑΔϖʔδදࣔͷߴԽ
/monthly
/daily
44%
10%
ཌͷ
༧ఆ֬ೝ͠Α͏ʂ
࣍ͷߦಈΛ༧
APIͷΞΫηεϩά͔ΒΛਪଌ
Research user action from access logs
Rendering speed-up using Prefetch
Slide 52
Slide 52 text
BFF
Client API
Request Request
Learning
Server
.PEFM
Request
Slide 53
Slide 53 text
BFF
Client API
Request
SSR
Request
Response
Response
Learning
Server
.PEFM
Response
Request
୯७Ϛϧίϑաఔ
Markov process
Slide 54
Slide 54 text
BFF
Client API
Request
SSR
Request
Response
Response
Learning
Server
.PEFM
Response
Request
୯७Ϛϧίϑաఔ
Markov process
࣍ʹऔಘ͖͢ϦιʔεΛϔομʹೖ
#''JOKFDUTJOUPUIFIFBEFSSFTPVSDFTSFRVJSFEOFYU
Slide 55
Slide 55 text
BFF
Client API
Learning
Server
.PEFM
Parse Header
Pre-fetch Request
Slide 56
Slide 56 text
BFF
Client API
Learning
Server
.PEFM
Request Request
Response
Response
LRU-cache
SET
Slide 57
Slide 57 text
BFF
Client API
Learning
Server
.PEFM
LRU-cache
exist ?
click
Slide 58
Slide 58 text
BFF
Client API
Learning
Server
.PEFM
LRU-cache
exist ?
click
ߦಈ༧͕ ”͋ͨͬͨ” ࣌
When the expectation was met
Slide 59
Slide 59 text
BFF
Client API
Learning
Server
.PEFM
LRU-cache
GET
click
CSR
Slide 60
Slide 60 text
BFF
Client API
Learning
Server
.PEFM
LRU-cache
exist ?
click
ߦಈ༧͕ ”֎Εͨ” ࣌
When an expectation is missed
Slide 61
Slide 61 text
BFF
Client API
Learning
Server
.PEFM
click
CSR Request Request
Request
Response
Response
Response