SlideShare a Scribd company logo
LINE's messaging service
architecture underlying more than
200 million monthly active users,
and core techs
Yuto Kawamura

LINE Corp
Speaker introduction
• Yuto Kawamura

• Senior software engineer

• Apache Kafka contributor

• Joined: Apr, 2015(2 years 5
months)
About LINE
•Messaging service 

•More than 200 million active users1 in countries with top market
share like Japan, Taiwan, Thailand and Indonesia

•Many family services

•News 

•Music

•LIVE (Video streaming) 

1 As of June 2017. Sum of 4 countries: Japan, Taiwan, Thailand and Indonesia. 

Scale Metrics
Messages delivered 25 billion per day
Peak time Messages sent

(new year greetings)
420K per second
Total API requests per day 80 billion per day
Number of event records published > 150 billion per day
Accumulated analytics data 40PB
Messaging System
Architecture
LINE Apps
LEGY JP
LEGY DE
LEGY SG
Thrift RPC/HTTP
talk-server
Distributed Data Store
Distributed async
task processing
LEGY
• LINE Event Delivery Gateway

• API Gateway/Reverse Proxy

• Written in Erlang

• Deployed to many data centers all over the world

• Features focused on needs of implementing a messaging service

• Zero latency code hot swapping w/o closing client connections

• Durability thanks to Erlang process and message passing

• Single instance holds 100K ~ connection per instance =>
huge impact by single instance failure
talk-server
• Java based web application server

• Implements most of messaging functionality + some other
features

• Java8 + Spring + Thrift RPC + Tomcat8
Datastore with Redis and
HBase
• LINE’s hybrid datastore =
Redis(in-memory DB, home-
brew clustering) +
HBase(persistent distributed
key-value store)

• Cascading failure handling

• Async write in app

• Async write from background
task processor

• Data correction batch
Primary/
Backup
talk-server
Cache/
Primary
Dual write
When user sends a
message
LEGY
LEGY
talk-server
Storage
1. Find nearest LEGY
2. sendMessage(“Bob”, “Hello!”)
3. Proxy request
4. Write to storage
talk-server
X. fetchOps()
6. Proxy request
7. Read message
8. Return fetchOps() with message
5. Notify message arrival
Alice
Bob
Communication between
internal systems
• Communication for queuing, transactional
updates:

• Query authentication/permission

• Synchronous updates
• Communication for data synchronization, update
notification:

• Notify user’s relationship update

• Synchronize data update with another service
talk-server
Auth
Analytics
Another
Service
HTTP/REST/RPC
Deeper look of some
core components
• Asynchronous HTTP/2 RPC/REST client/server library

• Built on top of Java8, Netty and RPC frameworks

• Open sourced: https://github.com/line/armeria

• Find more details: https://speakerdeck.com/trustin/
armeria-lines-next-generation-rpc-layer
Armeria
DocService
• Quick API test call + Documentation
sb.serviceUnder("/docs", new DocServiceBuilder()
.exampleHttpHeaders(HttpHeaders.of(AUTHORIZATION, "bearer b03c4fed1a"))
.exampleRequest(new HelloService.hello_args("Armeria"))
.build());
Other features
• Client side load balancer

• Retrieve server list from pluggable centralized
configuration directory and use for load balancing

• Structured logging

• Supports logging request/response including payload
of RPC

• Supports external system as an output such as Apache
Kafka
Armeria
• Most of new services are built on top of Armeria

• and some old projects are/will be rewritten based on it

• Sophisticated yet minimum LINE’s “best practices”

• PRs of line/armeria would be worth visiting for you

• https://github.com/line/armeria/pulls

• You will see how LINE developers are working for
development
Apache Kafka
• A distributed streaming platform

• (narrow sense) A distributed persistent message queue
which supports Pub-Sub model

• Built-in load distribution

• Built-in fail-over on both server(broker) and client
How it works
Producer
Brokers
Consumer
Topic
Topic
Consumer
Consumer
Producer
AuthEvent event = AuthEvent.newBuilder()
.setUserId(123)
.setEventType(AuthEventType.REGISTER)
.build();
producer.send(new
ProducerRecord(“events", userId, event));
consumer = new KafkaConsumer("group.id" ->
"group-A");
consumer.subscribe("events");
consumer.poll(100)…
// => Record(key=123, value=...)
Consumer GroupA
Pub-Sub
Brokers
Consumer
Topic
Topic
Consumer
Consumer GroupB
Consumer
Consumer
Records[A, B, C…]
Records[A, B, C…]
• Multiple consumer “groups” can
independently consume a single topic
Example: UserActivityEvent
Today’s Kafka usage
However…
• OSS usually isn’t a perfect solution

• We add/fix what we need

• Typically we need more than others, because of our
scale and challenging usages

• https://issues.apache.org/jira/browse/KAFKA-4614

• https://issues.apache.org/jira/browse/KAFKA-4024
Sometimes we contribute
Sometimes we share
• Kafka Summit SF 2017

• One Day, One Data Hub, 100
Billion Messages: Kafka at
LINE

• https://youtu.be/
X1zwbmLYPZg
but we have more things to
do
• Performance improvement to enable true stability

• Kafka based reliable async task processing system

• Multi-DC deployment
Summary
• LINE’s server architecture is keep evolving

• Almost everything are “Distributed”

• Software we use:

• Java/Earlang/Redis/HBase/Kafka/Armeria

• We love OSS

• we Use/Understand/Develop/Contribute

• and it’s encouraged

• 6 years since we started our service, still have many challenges

• More stable and durable service architecture 

• Dealing with a lot of new feature developments

• There are a lot of chances you make a great contribution to our systems and services,
please come and talk to me!
End of presentation.
Any questions?

More Related Content

PDF
Scalability, Availability & Stability Patterns
PDF
Apache Kafka Architecture & Fundamentals Explained
PDF
A Thorough Comparison of Delta Lake, Iceberg and Hudi
PDF
The Dual write problem
PPTX
Introduction to Apache ZooKeeper
PDF
Introduction to Kafka Streams
PPTX
Stability Patterns for Microservices
PPTX
Apache Kafka Best Practices
Scalability, Availability & Stability Patterns
Apache Kafka Architecture & Fundamentals Explained
A Thorough Comparison of Delta Lake, Iceberg and Hudi
The Dual write problem
Introduction to Apache ZooKeeper
Introduction to Kafka Streams
Stability Patterns for Microservices
Apache Kafka Best Practices

What's hot (20)

PPTX
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
PDF
Simplify CDC Pipeline with Spark Streaming SQL and Delta Lake
PPTX
From cache to in-memory data grid. Introduction to Hazelcast.
PDF
Performant Streaming in Production: Preventing Common Pitfalls when Productio...
PPTX
Kafka 101
PPTX
Domain Driven Design
PDF
Fundamentals of Apache Kafka
PDF
Introduction to Apache Flink - Fast and reliable big data processing
PDF
Introduction to Redis
PDF
Deep Dive: Memory Management in Apache Spark
PDF
The Apache Spark File Format Ecosystem
PDF
Apache Kafka Fundamentals for Architects, Admins and Developers
PDF
Implementing Domain Events with Kafka
PPTX
Where is my bottleneck? Performance troubleshooting in Flink
PDF
Disaster Recovery Plans for Apache Kafka
PDF
Big data real time architectures
PPTX
Processing Semantically-Ordered Streams in Financial Services
PDF
How Uber scaled its Real Time Infrastructure to Trillion events per day
PPTX
The Missing Manual for Leveled Compaction Strategy (Wei Deng & Ryan Svihla, D...
PDF
Understanding and Improving Code Generation
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
Simplify CDC Pipeline with Spark Streaming SQL and Delta Lake
From cache to in-memory data grid. Introduction to Hazelcast.
Performant Streaming in Production: Preventing Common Pitfalls when Productio...
Kafka 101
Domain Driven Design
Fundamentals of Apache Kafka
Introduction to Apache Flink - Fast and reliable big data processing
Introduction to Redis
Deep Dive: Memory Management in Apache Spark
The Apache Spark File Format Ecosystem
Apache Kafka Fundamentals for Architects, Admins and Developers
Implementing Domain Events with Kafka
Where is my bottleneck? Performance troubleshooting in Flink
Disaster Recovery Plans for Apache Kafka
Big data real time architectures
Processing Semantically-Ordered Streams in Financial Services
How Uber scaled its Real Time Infrastructure to Trillion events per day
The Missing Manual for Leveled Compaction Strategy (Wei Deng & Ryan Svihla, D...
Understanding and Improving Code Generation
Ad

Similar to LINE's messaging service architecture underlying more than 200 million monthly active users, and core techs (20)

PDF
Building a company-wide data pipeline on Apache Kafka - engineering for 150 b...
PDF
Building a company-wide data pipeline on Apache Kafka - engineering for 150 b...
PDF
Apache Kafka - Free Friday
PPTX
Captial One: Why Stream Data as Part of Data Transformation?
PPTX
What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...
PDF
Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...
PPTX
Kafka for data scientists
PPTX
Reducing Microservice Complexity with Kafka and Reactive Streams
PPTX
Distributed messaging through Kafka
PDF
Real-time Streams & Logs with Storm and Kafka by Andrew Montalenti and Keith ...
PDF
Real-time streams and logs with Storm and Kafka
PDF
Actors or Not: Async Event Architectures
PDF
Recipes to develop a reactive and cloud-ready application using Scala and Akka
PPTX
Reactive Streams - László van den Hoek
PPTX
Current and Future of Apache Kafka
PPTX
AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...
PDF
Eugene Letuchy Erlangat Facebook
PPTX
Microservices in a Streaming World
PDF
Akka A to Z: A Guide To The Industry’s Best Toolkit for Fast Data and Microse...
PDF
Agile Lab_BigData_Meetup_AKKA
Building a company-wide data pipeline on Apache Kafka - engineering for 150 b...
Building a company-wide data pipeline on Apache Kafka - engineering for 150 b...
Apache Kafka - Free Friday
Captial One: Why Stream Data as Part of Data Transformation?
What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...
Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...
Kafka for data scientists
Reducing Microservice Complexity with Kafka and Reactive Streams
Distributed messaging through Kafka
Real-time Streams & Logs with Storm and Kafka by Andrew Montalenti and Keith ...
Real-time streams and logs with Storm and Kafka
Actors or Not: Async Event Architectures
Recipes to develop a reactive and cloud-ready application using Scala and Akka
Reactive Streams - László van den Hoek
Current and Future of Apache Kafka
AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...
Eugene Letuchy Erlangat Facebook
Microservices in a Streaming World
Akka A to Z: A Guide To The Industry’s Best Toolkit for Fast Data and Microse...
Agile Lab_BigData_Meetup_AKKA
Ad

More from kawamuray (7)

PDF
Kafka Multi-Tenancy - 160 Billion Daily Messages on One Shared Cluster at LINE
PDF
Multitenancy: Kafka clusters for everyone at LINE
PDF
Kafka meetup JP #3 - Engineering Apache Kafka at LINE
PDF
Monitoring Kafka w/ Prometheus
PDF
Docker + Checkpoint/Restore
PDF
LXC on Ganeti
PDF
Norikraでアプリログを集計してリアルタイムエラー通知 # Norikra meetup
Kafka Multi-Tenancy - 160 Billion Daily Messages on One Shared Cluster at LINE
Multitenancy: Kafka clusters for everyone at LINE
Kafka meetup JP #3 - Engineering Apache Kafka at LINE
Monitoring Kafka w/ Prometheus
Docker + Checkpoint/Restore
LXC on Ganeti
Norikraでアプリログを集計してリアルタイムエラー通知 # Norikra meetup

Recently uploaded (20)

PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Welding lecture in detail for understanding
DOCX
573137875-Attendance-Management-System-original
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
PPT on Performance Review to get promotions
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Structs to JSON How Go Powers REST APIs.pdf
Lesson 3_Tessellation.pptx finite Mathematics
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Welding lecture in detail for understanding
573137875-Attendance-Management-System-original
CH1 Production IntroductoryConcepts.pptx
Foundation to blockchain - A guide to Blockchain Tech
CYBER-CRIMES AND SECURITY A guide to understanding
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Model Code of Practice - Construction Work - 21102022 .pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPT on Performance Review to get promotions
Operating System & Kernel Study Guide-1 - converted.pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Internet of Things (IOT) - A guide to understanding
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
OOP with Java - Java Introduction (Basics)
Structs to JSON How Go Powers REST APIs.pdf

LINE's messaging service architecture underlying more than 200 million monthly active users, and core techs

  • 1. LINE's messaging service architecture underlying more than 200 million monthly active users, and core techs Yuto Kawamura LINE Corp
  • 2. Speaker introduction • Yuto Kawamura • Senior software engineer • Apache Kafka contributor • Joined: Apr, 2015(2 years 5 months)
  • 3. About LINE •Messaging service •More than 200 million active users1 in countries with top market share like Japan, Taiwan, Thailand and Indonesia
 •Many family services •News •Music •LIVE (Video streaming) 
 1 As of June 2017. Sum of 4 countries: Japan, Taiwan, Thailand and Indonesia. 

  • 4. Scale Metrics Messages delivered 25 billion per day Peak time Messages sent
 (new year greetings) 420K per second Total API requests per day 80 billion per day Number of event records published > 150 billion per day Accumulated analytics data 40PB
  • 5. Messaging System Architecture LINE Apps LEGY JP LEGY DE LEGY SG Thrift RPC/HTTP talk-server Distributed Data Store Distributed async task processing
  • 6. LEGY • LINE Event Delivery Gateway • API Gateway/Reverse Proxy • Written in Erlang • Deployed to many data centers all over the world • Features focused on needs of implementing a messaging service • Zero latency code hot swapping w/o closing client connections • Durability thanks to Erlang process and message passing • Single instance holds 100K ~ connection per instance => huge impact by single instance failure
  • 7. talk-server • Java based web application server • Implements most of messaging functionality + some other features • Java8 + Spring + Thrift RPC + Tomcat8
  • 8. Datastore with Redis and HBase • LINE’s hybrid datastore = Redis(in-memory DB, home- brew clustering) + HBase(persistent distributed key-value store) • Cascading failure handling • Async write in app • Async write from background task processor • Data correction batch Primary/ Backup talk-server Cache/ Primary Dual write
  • 9. When user sends a message LEGY LEGY talk-server Storage 1. Find nearest LEGY 2. sendMessage(“Bob”, “Hello!”) 3. Proxy request 4. Write to storage talk-server X. fetchOps() 6. Proxy request 7. Read message 8. Return fetchOps() with message 5. Notify message arrival Alice Bob
  • 10. Communication between internal systems • Communication for queuing, transactional updates: • Query authentication/permission • Synchronous updates • Communication for data synchronization, update notification: • Notify user’s relationship update • Synchronize data update with another service talk-server Auth Analytics Another Service HTTP/REST/RPC
  • 11. Deeper look of some core components
  • 12. • Asynchronous HTTP/2 RPC/REST client/server library • Built on top of Java8, Netty and RPC frameworks • Open sourced: https://github.com/line/armeria • Find more details: https://speakerdeck.com/trustin/ armeria-lines-next-generation-rpc-layer Armeria
  • 13. DocService • Quick API test call + Documentation sb.serviceUnder("/docs", new DocServiceBuilder() .exampleHttpHeaders(HttpHeaders.of(AUTHORIZATION, "bearer b03c4fed1a")) .exampleRequest(new HelloService.hello_args("Armeria")) .build());
  • 14. Other features • Client side load balancer • Retrieve server list from pluggable centralized configuration directory and use for load balancing • Structured logging • Supports logging request/response including payload of RPC • Supports external system as an output such as Apache Kafka
  • 15. Armeria • Most of new services are built on top of Armeria • and some old projects are/will be rewritten based on it • Sophisticated yet minimum LINE’s “best practices” • PRs of line/armeria would be worth visiting for you • https://github.com/line/armeria/pulls • You will see how LINE developers are working for development
  • 16. Apache Kafka • A distributed streaming platform • (narrow sense) A distributed persistent message queue which supports Pub-Sub model • Built-in load distribution • Built-in fail-over on both server(broker) and client
  • 17. How it works Producer Brokers Consumer Topic Topic Consumer Consumer Producer AuthEvent event = AuthEvent.newBuilder() .setUserId(123) .setEventType(AuthEventType.REGISTER) .build(); producer.send(new ProducerRecord(“events", userId, event)); consumer = new KafkaConsumer("group.id" -> "group-A"); consumer.subscribe("events"); consumer.poll(100)… // => Record(key=123, value=...)
  • 18. Consumer GroupA Pub-Sub Brokers Consumer Topic Topic Consumer Consumer GroupB Consumer Consumer Records[A, B, C…] Records[A, B, C…] • Multiple consumer “groups” can independently consume a single topic
  • 21. However… • OSS usually isn’t a perfect solution • We add/fix what we need • Typically we need more than others, because of our scale and challenging usages • https://issues.apache.org/jira/browse/KAFKA-4614 • https://issues.apache.org/jira/browse/KAFKA-4024
  • 23. Sometimes we share • Kafka Summit SF 2017 • One Day, One Data Hub, 100 Billion Messages: Kafka at LINE • https://youtu.be/ X1zwbmLYPZg
  • 24. but we have more things to do • Performance improvement to enable true stability • Kafka based reliable async task processing system • Multi-DC deployment
  • 25. Summary • LINE’s server architecture is keep evolving • Almost everything are “Distributed” • Software we use: • Java/Earlang/Redis/HBase/Kafka/Armeria • We love OSS • we Use/Understand/Develop/Contribute • and it’s encouraged • 6 years since we started our service, still have many challenges • More stable and durable service architecture • Dealing with a lot of new feature developments • There are a lot of chances you make a great contribution to our systems and services, please come and talk to me!