Tech behind
LINE QR Code Login
Agenda 1. What is LINE Login?
2. Tech behind LINE QR Code Login
1. System Architecture
2. Spring WebFlux
Agenda 1. What is LINE Login?
2. Tech behind LINE QR Code Login
1. System Architecture
2. Spring WebFlux
• Social Login Service
• OAuth 2.0 / OpenID Connect 1.0
• Extended Features
• Messaging / Profile APIs
• Auto Login on smartphone web browser
• QR Code Login on PC web browser NEW!
• FIDO2 Support COMING SOON!
What is LINE Login?
What is QR Code Login?
Agenda 1. What is LINE Login?
2. Tech behind LINE QR Code Login
1. System Architecture
2. Spring WebFlux
backend
servers
System Architecture
REST/thrift
backend APIs
Login server
QR Code
Login server
gateway
server
web browser Redis Cluster
Session Storage
long polling
long polling
gateway
server
LINE
client app
QR Code Read Event
QR Code Read Event
Redis
PubSub
System Architecture
QR Code
Login server
web browser
long polling for sessionId
QR Code Read Event
including sessionId
Redis
PubSub
LINE
client app
via gateway server
via gateway/backend server
QR Code
Login server
publish to channel-{sessionId}
subscribe channel-{sessionId}
・・・・・
QR Code
including
sessionId
Agenda 1. What is LINE Login?
2. Tech behind LINE QR Code Login
1. System Architecture
2. Spring WebFlux
● Each requests block and occupy a thread
up to 3 minutes
● Web framework based on event loop
concurrency model
● Each reqeusts do not block and do share the
thread
Spring WebFlux
request
request
request
request
request
request
Spring MVC (Servlet API)
Spring WebFlux
WebFlux with WebMVC
dependency
spring-boot-
starter-web
○ ○ -
WebApplicationType (default) REACTIVE (default)
Filter ServletFilter WebFilter WebFilter
ThreadLocal OK ✗ ✗
@Controller Style OK OK OK
App Container Servlet
Reactive
via 'ServletAdapter'
Reactive
Reactive Style can block thread *1 OK *1 OK
MVC (blocking) Style block thread block thread block thread
*1 Flux stream operation runs on @Async threads
WebFlux with WebMVC
dependency
spring-boot-
starter-web
○ ○ -
WebApplicationType (default) REACTIVE (default)
Filter ServletFilter WebFilter WebFilter
ThreadLocal OK ✗ ✗
@Controller Style OK OK OK
App Container Servlet
Reactive
via 'ServletAdapter'
Reactive
Reactive Style can block thread *1 OK *1 OK
MVC (blocking) Style block thread block thread block thread
*1 Flux stream operation runs on @Async threads
want to reuse
component
WebFlux with WebMVC
dependency
spring-boot-
starter-web
○ ○ -
WebApplicationType (default) REACTIVE (default)
Filter ServletFilter WebFilter WebFilter
ThreadLocal OK ✗ ✗
@Controller Style OK OK OK
App Container Servlet
Reactive
via 'ServletAdapter'
Reactive
Reactive Style can block thread *1 OK *1 OK
MVC (blocking) Style block thread block thread block thread
*1 Flux stream operation runs on @Async threads
thread blocked
WebFlux with WebMVC
dependency
spring-boot-
starter-web
○ ○ -
WebApplicationType (default) REACTIVE (default)
Filter ServletFilter WebFilter WebFilter
ThreadLocal OK ✗ ✗
@Controller Style OK OK OK
App Container Servlet
Reactive
via 'ServletAdapter'
Reactive
Reactive Style can block thread *1 OK *1 OK
MVC (blocking) Style block thread block thread block thread
*1 Flux stream operation runs on @Async threads
Hybrid container is expected....but ,actually,
both style code runs on same container and
same thread pool
WebFlux with WebMVC
dependency
spring-boot-
starter-web
○ ○ -
WebApplicationType (default) REACTIVE (default)
Filter ServletFilter WebFilter WebFilter
ThreadLocal OK ✗ ✗
@Controller Style OK OK OK
App Container Servlet
Reactive
via 'ServletAdapter'
Reactive
Reactive Style can block thread *1 OK *1 OK
MVC (blocking) Style block thread block thread block thread
*1 Flux stream operation runs on @Async threads
cannot reuse
component
WebFlux with WebMVC
dependency
spring-boot-
starter-web
○ ○ -
WebApplicationType (default) REACTIVE (default)
Filter ServletFilter WebFilter WebFilter
ThreadLocal OK ✗ ✗
@Controller Style OK OK OK
App Container Servlet
Reactive
via 'ServletAdapter'
Reactive
Reactive Style can block thread *1 OK *1 OK
MVC (blocking) Style block thread block thread block thread
*1 Flux stream operation runs on @Async threads
'Pure' WebFlux applied'Pure' WebFlux applied
WebFlux with WebMVC
dependency
spring-boot-
starter-web
○ ○ -
WebApplicationType (default) REACTIVE (default)
Filter ServletFilter WebFilter WebFilter
ThreadLocal OK ✗ ✗
@Controller Style OK OK OK
App Container Servlet
Reactive
via 'ServletAdapter'
Reactive
Reactive Style can block thread *1 OK *1 OK
MVC (blocking) Style block thread block thread block thread
*1 Flux stream operation runs on @Async threads
need to rewrite ServletFilter
need ThreadLocal alternative
WebFilter
ServletFilter WebFilter
blocking OK NG
request HttpServerRequest ServerWebExchge.request
response HttpServerResponse ServerWebExchge.response
request
attri
butes
HttpServerRequest.attributes[] ServerWebExchange.attributes[]
req/res
cont
ent
HttpServletRequestWrapper
Http
ServletResponseWrapper
ServerHttpRequestDecorator
Ser
verHttpResponseDecorator
status code HttpServerResponse.status
ServerWebExchge.response
.statusCode
*1. null means 200OK
2. Reactive style code is needed.
3. Some data cannot be retrieved in later stage.
WebFilter
← 3
← 2
A. Reactive style code is needed.
B. Request/response content is passed as Publisher<out DataBuffer>.
C. DataBuffer can be duplicated as java.nio.ByteBuffer.
WebFilter - ServerHttp*Decorator
← B
← A
← C
- HttpServlet*Wrapper alternative -
A. Take care of invocation order
Subscriber Context
- ThreadLocal alternative -
......
WebFilter UserLogic
1
2
3
4
B. Take care of propagate direction
Subscriber Context
- ThreadLocal alternative -
......
WebFilter UserLogic
B. Take care of propagate direction
Subscriber Context
- ThreadLocal alternative -
......
WebFilter UserLogic
Cannot read here
• PubSub
• Redis + Sentinel
• Log Aggregation
• kafka --> kafka-streams --> fluentd
• HBase + Hive + MySQL
• Web Application Server
• Kotlin
• Spring WebFlux + Reactor
• Lettuce
• Micrometer + Spring Actuator + Prometheus + Grafana
Other topics
THANK YOU

Technologies That Make LINE QR Code Login Possible

  • 1.
  • 2.
    Agenda 1. Whatis LINE Login? 2. Tech behind LINE QR Code Login 1. System Architecture 2. Spring WebFlux
  • 3.
    Agenda 1. Whatis LINE Login? 2. Tech behind LINE QR Code Login 1. System Architecture 2. Spring WebFlux
  • 4.
    • Social LoginService • OAuth 2.0 / OpenID Connect 1.0 • Extended Features • Messaging / Profile APIs • Auto Login on smartphone web browser • QR Code Login on PC web browser NEW! • FIDO2 Support COMING SOON! What is LINE Login?
  • 5.
    What is QRCode Login?
  • 6.
    Agenda 1. Whatis LINE Login? 2. Tech behind LINE QR Code Login 1. System Architecture 2. Spring WebFlux
  • 7.
    backend servers System Architecture REST/thrift backend APIs Loginserver QR Code Login server gateway server web browser Redis Cluster Session Storage long polling long polling gateway server LINE client app QR Code Read Event QR Code Read Event Redis PubSub
  • 8.
    System Architecture QR Code Loginserver web browser long polling for sessionId QR Code Read Event including sessionId Redis PubSub LINE client app via gateway server via gateway/backend server QR Code Login server publish to channel-{sessionId} subscribe channel-{sessionId} ・・・・・ QR Code including sessionId
  • 9.
    Agenda 1. Whatis LINE Login? 2. Tech behind LINE QR Code Login 1. System Architecture 2. Spring WebFlux
  • 10.
    ● Each requestsblock and occupy a thread up to 3 minutes ● Web framework based on event loop concurrency model ● Each reqeusts do not block and do share the thread Spring WebFlux request request request request request request Spring MVC (Servlet API) Spring WebFlux
  • 11.
    WebFlux with WebMVC dependency
spring-boot- starter-web ○○ - WebApplicationType (default) REACTIVE (default) Filter ServletFilter WebFilter WebFilter ThreadLocal OK ✗ ✗ @Controller Style OK OK OK App Container Servlet Reactive via 'ServletAdapter' Reactive Reactive Style can block thread *1 OK *1 OK MVC (blocking) Style block thread block thread block thread *1 Flux stream operation runs on @Async threads
  • 12.
    WebFlux with WebMVC dependency
spring-boot- starter-web ○○ - WebApplicationType (default) REACTIVE (default) Filter ServletFilter WebFilter WebFilter ThreadLocal OK ✗ ✗ @Controller Style OK OK OK App Container Servlet Reactive via 'ServletAdapter' Reactive Reactive Style can block thread *1 OK *1 OK MVC (blocking) Style block thread block thread block thread *1 Flux stream operation runs on @Async threads want to reuse component
  • 13.
    WebFlux with WebMVC dependency
spring-boot- starter-web ○○ - WebApplicationType (default) REACTIVE (default) Filter ServletFilter WebFilter WebFilter ThreadLocal OK ✗ ✗ @Controller Style OK OK OK App Container Servlet Reactive via 'ServletAdapter' Reactive Reactive Style can block thread *1 OK *1 OK MVC (blocking) Style block thread block thread block thread *1 Flux stream operation runs on @Async threads thread blocked
  • 14.
    WebFlux with WebMVC dependency
spring-boot- starter-web ○○ - WebApplicationType (default) REACTIVE (default) Filter ServletFilter WebFilter WebFilter ThreadLocal OK ✗ ✗ @Controller Style OK OK OK App Container Servlet Reactive via 'ServletAdapter' Reactive Reactive Style can block thread *1 OK *1 OK MVC (blocking) Style block thread block thread block thread *1 Flux stream operation runs on @Async threads Hybrid container is expected....but ,actually, both style code runs on same container and same thread pool
  • 15.
    WebFlux with WebMVC dependency
spring-boot- starter-web ○○ - WebApplicationType (default) REACTIVE (default) Filter ServletFilter WebFilter WebFilter ThreadLocal OK ✗ ✗ @Controller Style OK OK OK App Container Servlet Reactive via 'ServletAdapter' Reactive Reactive Style can block thread *1 OK *1 OK MVC (blocking) Style block thread block thread block thread *1 Flux stream operation runs on @Async threads cannot reuse component
  • 16.
    WebFlux with WebMVC dependency
spring-boot- starter-web ○○ - WebApplicationType (default) REACTIVE (default) Filter ServletFilter WebFilter WebFilter ThreadLocal OK ✗ ✗ @Controller Style OK OK OK App Container Servlet Reactive via 'ServletAdapter' Reactive Reactive Style can block thread *1 OK *1 OK MVC (blocking) Style block thread block thread block thread *1 Flux stream operation runs on @Async threads 'Pure' WebFlux applied'Pure' WebFlux applied
  • 17.
    WebFlux with WebMVC dependency
spring-boot- starter-web ○○ - WebApplicationType (default) REACTIVE (default) Filter ServletFilter WebFilter WebFilter ThreadLocal OK ✗ ✗ @Controller Style OK OK OK App Container Servlet Reactive via 'ServletAdapter' Reactive Reactive Style can block thread *1 OK *1 OK MVC (blocking) Style block thread block thread block thread *1 Flux stream operation runs on @Async threads need to rewrite ServletFilter need ThreadLocal alternative
  • 18.
    WebFilter ServletFilter WebFilter blocking OKNG request HttpServerRequest ServerWebExchge.request response HttpServerResponse ServerWebExchge.response request
attri butes HttpServerRequest.attributes[] ServerWebExchange.attributes[] req/res
cont ent HttpServletRequestWrapper
Http ServletResponseWrapper ServerHttpRequestDecorator
Ser verHttpResponseDecorator status code HttpServerResponse.status ServerWebExchge.response .statusCode *1. null means 200OK
  • 19.
    2. Reactive stylecode is needed. 3. Some data cannot be retrieved in later stage. WebFilter ← 3 ← 2
  • 20.
    A. Reactive stylecode is needed. B. Request/response content is passed as Publisher<out DataBuffer>. C. DataBuffer can be duplicated as java.nio.ByteBuffer. WebFilter - ServerHttp*Decorator ← B ← A ← C - HttpServlet*Wrapper alternative -
  • 21.
    A. Take careof invocation order Subscriber Context - ThreadLocal alternative - ...... WebFilter UserLogic 1 2 3 4
  • 22.
    B. Take careof propagate direction Subscriber Context - ThreadLocal alternative - ...... WebFilter UserLogic
  • 23.
    B. Take careof propagate direction Subscriber Context - ThreadLocal alternative - ...... WebFilter UserLogic Cannot read here
  • 24.
    • PubSub • Redis+ Sentinel • Log Aggregation • kafka --> kafka-streams --> fluentd • HBase + Hive + MySQL • Web Application Server • Kotlin • Spring WebFlux + Reactor • Lettuce • Micrometer + Spring Actuator + Prometheus + Grafana Other topics
  • 25.