SlideShare une entreprise Scribd logo
1  sur  69
Front-End APIs
Powering Fast-Paced Product Iterations
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
linkedin-api-modeling
Presented at QCon New York
www.qconnewyork.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Speakers
​Jeff Weiner
​Chief Executive Officer
​Aditya Modi
​Staff Software Engineer
​Karthik Ramgopal
​Sr Staff Software Engineer
Overview
History and evolution of frontend APIs at LinkedIn
Our API structure today
Learnings and results
Sneak peek at the future
2 Years Ago
Mobile v/s Desktop
Feed on mobile Feed on desktopFeed on iPad
Client - Server setup
mobile-frontend-API tablet-frontend-API homepage-frontend-API profile-frontend-API
Android iOS Tablet homepage-desktop-web profile-desktop-web
• Huge API surface and diversity
• No IDL/schema backing API
• Slow iteration speed
Problems?
Today
Mobile v/s Desktop
Feed on mobile Feed on desktopFeed on iPad
Client - Server setup
flagship-frontend-API
flagship-android flagship-iOS flagship-desktop-webflagship-mobile-web
Rest + JSON over HTTP2
Mid-tier . . . . Mid-tier
• > 120k QPS
• ~425 developers
• ~30 commits per day
Scale
• Automated continuous release
• commit to production in < 3 hours
• 3 deployments a day
3x3 Deployment
Modeling
• Backed by Strongly Typed Schemas
• Backward-compatible evolution
• No endpoint versioning
Principles
{
"type": "record",
"name": "TestRecord",
"namespace": "com.linkedin.test",
"doc": "Test",
"fields": [
{
"name": "id",
"type": "String",
"doc": "ID"
},
{
"name": "name",
"type": "String",
"doc": "Name",
“optional”: true
},
]
}
@interface TestRecord : NSObject
@property(nonnull, copy) NSString *id;
@property(nullable, copy) NSString *name;
@end
class TestRecord {
@NonNull public final String id;
@Nullable public final String name;
}
export default DS.Model.extend({
id: DS.attr(‘string’),
name: DS.attr(‘string’)
});
Schema definition
iOS
Android
Web
Entity Modeling
• Return - Collection<Card>
Composite screens
● Two top level resources
■ Invitations
■ PYMK (People You May Know)
● 1 network call to fetch both resources
■ Infrastructure level aggregation support
• Easy to model
• Decouple API from UI
• Client side consistency
Advantages
Client side consistency
Client side consistency
• Why ?
○ Good UX
○ Optimistic writes
Client side consistency
Can you do this auto-magically?
Client side consistency
Payload Cache
Client side consistency
Payload Cache
Client side consistency
Cache Payload
Everything is awesome, right?
Takes a long time to ship a feature
API Server
1.5 weeks
iOS
2 weeks
Android
2 weeks
Web
2 weeks
Total time
3.5 weeks=+
Use case: Introduce a new kind of notification
• Create new models for every feature
• Write code on each client platform
• Wait for native app release/adoption
Why so long?
Challenge
Cut this down to 1 day!
• Quickly build and release notifications
• Increase user engagement
• Sweet and sticky, just like honey!
Project Honeycomb
• New notifications WITHOUT app updates
• Client side consistency
• Stellar runtime performance
Beyond iteration speed...
• Model based on how the UI view looks
• Similar views grouped into 1 template
• More UI specific logic on API server
View Template API
Share notification
Share Template
● PrimaryImage: URL?
● Title: AttributedString
● Timestamp: Long
● ShareImage: URL?
● ShareTitle: String
● LikeCount: Long? (Default: 0)
● CommentCount: Long? (Default: 0)
Now let’s look at a slightly different notification
Modify Share Template
● PrimaryImage: URL?
● Title: AttributedString
● Timestamp: Long
● ShareImage: URL?
● ShareTitle: String AttributedString
● ShareSubtitle: AttributedString?
● LikeCount: Long? (Default: 0)
● CommentCount: Long? (Default: 0)
How about something radically different?
Work Anniversary Template
● PrimaryImage: URL?
● Title: AttributedString
● Timestamp: Long
Something slightly different again?
Work Anniversary/New Position Template
● PrimaryImage: URL?
● Title: AttributedString
● Timestamp: Long
● BodyText: AttributedString?
How do we return a heterogeneous list?
• Use Rest.li paginated collections. Differentiate between items using a Union.
• JSON payload structure:
{
“elements” : [
{“Share”: {“Title”: “Sarah Clatterbuck shared a…”, ...}},
{“Anniversary”: {“Title”: “Congratulate Nitish Jha…”, ...}},
....
],
“paging”: { “start” : 0, “count”: 10, “paginationToken”: “xydsad”}
}
Minor payload optimization
• Embed the type into the payload to reduce nesting.
• JSON payload structure:
{
“elements” : [
{“Type”: “Share”, “Title”: “Sarah Clatterbuck shared a…”, ...},
{“Type”: “Anniversary”, “Title”: “Congratulate Nitish Jha…”, ...},
....
],
“paging”: { “start” : 0, “count”: 10, “paginationToken”: “xydsad”}
}
• Code-generated response parser
• Bind model to native views
• Write once* per layout, reuse.
Client side rendering
Backward compatibility
{
“elements” : [
{“Stat”: {“Title”: “Your Profile...”, ...}},
{“JYMBII”: {“Title”: “5 Jobs you”, ...}},
{“Share”: {“Title”: “Swati Mathur...”, ...}},
....
],
“paging”: { “start” : 0, “count”: 10,
“paginationToken”: “xydsad”}
}
Drop unknown notification types.
Backward compatibility
Drop unknown fields based on product needs.
• New notification types without client
changes
• Renders faster on the client
Benefits
But… Client side Consistency is lost!
How do we solve this?
How did we solve the AttributedString problem?
• Model formatted text
• Control formatting from the server
• Impractical to use HTML
AttributedString
AttributedString schema
AttributedString
● Text: String
● Attributes: List[Attribute] BOLD, ITALIC, UNDERLINE etc.
Attribute
● Type: AttributeType
● StartIndex: Int
● Length: Int
● Metadata: Any?
Platform specific binding
Infrastructure provided support
iOS
Android
Web
NSAttributedString
Spannable
HTML
AttributedString
What if we extended this concept to entity mentions?
Model entity mentions also as a custom formatting specifier.
Profile mention Profile mention
Introducing TextViewModel
TextViewModel
● Text: String
● Attributes: List[TextViewAttribute]
TextViewAttribute
● Type: TextViewAttributeType
● StartIndex: Int
● Length: Int
● Metadata: Any?
● Profile: Profile?
● Job: Job?
● Company: Company?
● Course: Course?
Flattened canonical entities as optional fields
Similar to AttributedString
Entity mentions
Entities could be mentioned in different ways.
First Name
Full Name
Position
TextViewAttributeType
TextViewAttributeType
● PROFILE_FIRST_NAME
● PROFILE_FULL_NAME
● PROFILE_HEADLINE
● PROFILE_DISTANCE
● COMPANY_NAME
● COMPANY_HEADLINE
● JOB_TITLE
● ….
If a particular type is used, then the corresponding entity is populated by the server.
● PROFILE_XXX types will populate the profile field for example with the corresponding profile.
Backward compatibility++
Old clients cannot handle new mention types. Always send Raw text though redundant.
{
“title” : {
“Text”: “Sarah Clatterbuck shared this”,
“Attributes”: [
{“Type”: “PROFILE_FULL_NAME”,
“StartIndex”: 0….}
]
}
}
• Singular and Plurals
• Possessive forms
• i10n and i18n
Watch Out
How about images?
Use the same concept as TextViewModel. Introduce ImageViewModel.
ImageViewModel
● Attributes: List[ImageViewAttribute]
ImageViewAttribute
● ImageViewAttributeType
● URL: URL?
● ResourceName: String?
● Profile: Profile?
● Job: Job?
● Company: Company?
● Course: Course?
Flattened canonical entities as optional fields
ImageViewAttributeType
ImageViewAttributeType
● URL
● RESOURCE_NAME
● PROFILE_IMAGE
● PROFILE_BACKGROUND
● COMPANY_IMAGE
● ….
If a particular type is used, then the corresponding entity is populated by the server.
● PROFILE_XXX types will populate the profile field for example with the corresponding profile.
● URL type will populate the image URL
● RESOURCE_NAME will populate the pre-canned resource name.
Rendering Images
● Infra code extracts Image URL out of ImageViewModel
● Load into platform specific image view.
One Attribute: Regular ImageView
Multiple Attributes: GridImageView
Performance considerations
Entities may repeat multiple times within the same notification causing payload size bloat.
Tim’s Profile in ImageViewModel Tim’s Profile in TextViewModel
Solution: Response Normalization
All canonical entities have a unique ID. Use a JSON API like response format.
{
“data” : {
“Profile”: “profile:123”, ...
},
“included”: [
{
“id” : “profile:123”, “firstName” : “Tim”, “LastName” : “Jurka”, ... }
},
....
]
}
Performance considerations (Continued)
All fields from the entities may not be used.
ImageURL First Name and Last Name
Solution: Deco
Deco is a LinkedIn framework that allows selective projection and decoration of fields.
Profile in TextViewModel
ID
FirstName
LastName
Profile in ImageViewModel
ID
ImageURL
Profile in Response
ID
FirstName
LastName
ImageURL
Results
Improved Developer and Product Velocity
9 new notification types in all of 2016
16 new notification types in May and June 2017
API model reduction
42 API models for old UI
6 API models for new UI
Code size reduction
15k LOC app and test code for old UI
3k LOC app and test code for new UI
Future Direction
● Extend to other pages in Flagship
● Extend to other LinkedIn apps like JobSeeker, Recruiter etc.
Out of scope for this talk
● Intricate details of client side consistency management
● Generic Modeling of actions
● Challenges in migrating from the old notifications API to the new one
Find us after the talk, and we’re happy to chat about this and more.
Q & A
​amodi@linkedin.com
​https://www.linkedin.com/in/modiaditya/
​
​Aditya Modi
​kramgopal@linkedin.com
​https://www.linkedin.com/in/karthikrg/
​
​
​Karthik Ramgopal
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
linkedin-api-modeling

Contenu connexe

Plus de C4Media

Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsC4Media
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechC4Media
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/awaitC4Media
 
Opportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaOpportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaC4Media
 
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayDatadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayC4Media
 
Are We Really Cloud-Native?
Are We Really Cloud-Native?Are We Really Cloud-Native?
Are We Really Cloud-Native?C4Media
 
CockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseCockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseC4Media
 
A Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with BrooklinA Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with BrooklinC4Media
 

Plus de C4Media (20)

Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery Teams
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in Adtech
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/await
 
Opportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaOpportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven Utopia
 
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayDatadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
 
Are We Really Cloud-Native?
Are We Really Cloud-Native?Are We Really Cloud-Native?
Are We Really Cloud-Native?
 
CockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseCockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL Database
 
A Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with BrooklinA Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with Brooklin
 

Dernier

Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 

Dernier (20)

Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 

Front-End APIs: Powering Fast-Paced Iterations

  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ linkedin-api-modeling
  • 3. Presented at QCon New York www.qconnewyork.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 4. Speakers ​Jeff Weiner ​Chief Executive Officer ​Aditya Modi ​Staff Software Engineer ​Karthik Ramgopal ​Sr Staff Software Engineer
  • 5. Overview History and evolution of frontend APIs at LinkedIn Our API structure today Learnings and results Sneak peek at the future
  • 7. Mobile v/s Desktop Feed on mobile Feed on desktopFeed on iPad
  • 8. Client - Server setup mobile-frontend-API tablet-frontend-API homepage-frontend-API profile-frontend-API Android iOS Tablet homepage-desktop-web profile-desktop-web
  • 9. • Huge API surface and diversity • No IDL/schema backing API • Slow iteration speed Problems?
  • 10. Today
  • 11. Mobile v/s Desktop Feed on mobile Feed on desktopFeed on iPad
  • 12. Client - Server setup flagship-frontend-API flagship-android flagship-iOS flagship-desktop-webflagship-mobile-web Rest + JSON over HTTP2 Mid-tier . . . . Mid-tier
  • 13. • > 120k QPS • ~425 developers • ~30 commits per day Scale
  • 14. • Automated continuous release • commit to production in < 3 hours • 3 deployments a day 3x3 Deployment
  • 16. • Backed by Strongly Typed Schemas • Backward-compatible evolution • No endpoint versioning Principles
  • 17. { "type": "record", "name": "TestRecord", "namespace": "com.linkedin.test", "doc": "Test", "fields": [ { "name": "id", "type": "String", "doc": "ID" }, { "name": "name", "type": "String", "doc": "Name", “optional”: true }, ] } @interface TestRecord : NSObject @property(nonnull, copy) NSString *id; @property(nullable, copy) NSString *name; @end class TestRecord { @NonNull public final String id; @Nullable public final String name; } export default DS.Model.extend({ id: DS.attr(‘string’), name: DS.attr(‘string’) }); Schema definition iOS Android Web
  • 18. Entity Modeling • Return - Collection<Card>
  • 19. Composite screens ● Two top level resources ■ Invitations ■ PYMK (People You May Know) ● 1 network call to fetch both resources ■ Infrastructure level aggregation support
  • 20. • Easy to model • Decouple API from UI • Client side consistency Advantages
  • 22. Client side consistency • Why ? ○ Good UX ○ Optimistic writes
  • 23. Client side consistency Can you do this auto-magically?
  • 28. Takes a long time to ship a feature API Server 1.5 weeks iOS 2 weeks Android 2 weeks Web 2 weeks Total time 3.5 weeks=+ Use case: Introduce a new kind of notification
  • 29. • Create new models for every feature • Write code on each client platform • Wait for native app release/adoption Why so long?
  • 31. • Quickly build and release notifications • Increase user engagement • Sweet and sticky, just like honey! Project Honeycomb
  • 32. • New notifications WITHOUT app updates • Client side consistency • Stellar runtime performance Beyond iteration speed...
  • 33. • Model based on how the UI view looks • Similar views grouped into 1 template • More UI specific logic on API server View Template API
  • 34. Share notification Share Template ● PrimaryImage: URL? ● Title: AttributedString ● Timestamp: Long ● ShareImage: URL? ● ShareTitle: String ● LikeCount: Long? (Default: 0) ● CommentCount: Long? (Default: 0)
  • 35. Now let’s look at a slightly different notification Modify Share Template ● PrimaryImage: URL? ● Title: AttributedString ● Timestamp: Long ● ShareImage: URL? ● ShareTitle: String AttributedString ● ShareSubtitle: AttributedString? ● LikeCount: Long? (Default: 0) ● CommentCount: Long? (Default: 0)
  • 36. How about something radically different? Work Anniversary Template ● PrimaryImage: URL? ● Title: AttributedString ● Timestamp: Long
  • 37. Something slightly different again? Work Anniversary/New Position Template ● PrimaryImage: URL? ● Title: AttributedString ● Timestamp: Long ● BodyText: AttributedString?
  • 38. How do we return a heterogeneous list? • Use Rest.li paginated collections. Differentiate between items using a Union. • JSON payload structure: { “elements” : [ {“Share”: {“Title”: “Sarah Clatterbuck shared a…”, ...}}, {“Anniversary”: {“Title”: “Congratulate Nitish Jha…”, ...}}, .... ], “paging”: { “start” : 0, “count”: 10, “paginationToken”: “xydsad”} }
  • 39. Minor payload optimization • Embed the type into the payload to reduce nesting. • JSON payload structure: { “elements” : [ {“Type”: “Share”, “Title”: “Sarah Clatterbuck shared a…”, ...}, {“Type”: “Anniversary”, “Title”: “Congratulate Nitish Jha…”, ...}, .... ], “paging”: { “start” : 0, “count”: 10, “paginationToken”: “xydsad”} }
  • 40. • Code-generated response parser • Bind model to native views • Write once* per layout, reuse. Client side rendering
  • 41. Backward compatibility { “elements” : [ {“Stat”: {“Title”: “Your Profile...”, ...}}, {“JYMBII”: {“Title”: “5 Jobs you”, ...}}, {“Share”: {“Title”: “Swati Mathur...”, ...}}, .... ], “paging”: { “start” : 0, “count”: 10, “paginationToken”: “xydsad”} } Drop unknown notification types.
  • 42. Backward compatibility Drop unknown fields based on product needs.
  • 43. • New notification types without client changes • Renders faster on the client Benefits
  • 44. But… Client side Consistency is lost!
  • 45. How do we solve this?
  • 46. How did we solve the AttributedString problem? • Model formatted text • Control formatting from the server • Impractical to use HTML AttributedString
  • 47. AttributedString schema AttributedString ● Text: String ● Attributes: List[Attribute] BOLD, ITALIC, UNDERLINE etc. Attribute ● Type: AttributeType ● StartIndex: Int ● Length: Int ● Metadata: Any?
  • 48. Platform specific binding Infrastructure provided support iOS Android Web NSAttributedString Spannable HTML AttributedString
  • 49. What if we extended this concept to entity mentions? Model entity mentions also as a custom formatting specifier. Profile mention Profile mention
  • 50. Introducing TextViewModel TextViewModel ● Text: String ● Attributes: List[TextViewAttribute] TextViewAttribute ● Type: TextViewAttributeType ● StartIndex: Int ● Length: Int ● Metadata: Any? ● Profile: Profile? ● Job: Job? ● Company: Company? ● Course: Course? Flattened canonical entities as optional fields Similar to AttributedString
  • 51. Entity mentions Entities could be mentioned in different ways. First Name Full Name Position
  • 52. TextViewAttributeType TextViewAttributeType ● PROFILE_FIRST_NAME ● PROFILE_FULL_NAME ● PROFILE_HEADLINE ● PROFILE_DISTANCE ● COMPANY_NAME ● COMPANY_HEADLINE ● JOB_TITLE ● …. If a particular type is used, then the corresponding entity is populated by the server. ● PROFILE_XXX types will populate the profile field for example with the corresponding profile.
  • 53. Backward compatibility++ Old clients cannot handle new mention types. Always send Raw text though redundant. { “title” : { “Text”: “Sarah Clatterbuck shared this”, “Attributes”: [ {“Type”: “PROFILE_FULL_NAME”, “StartIndex”: 0….} ] } }
  • 54. • Singular and Plurals • Possessive forms • i10n and i18n Watch Out
  • 55. How about images? Use the same concept as TextViewModel. Introduce ImageViewModel. ImageViewModel ● Attributes: List[ImageViewAttribute] ImageViewAttribute ● ImageViewAttributeType ● URL: URL? ● ResourceName: String? ● Profile: Profile? ● Job: Job? ● Company: Company? ● Course: Course? Flattened canonical entities as optional fields
  • 56. ImageViewAttributeType ImageViewAttributeType ● URL ● RESOURCE_NAME ● PROFILE_IMAGE ● PROFILE_BACKGROUND ● COMPANY_IMAGE ● …. If a particular type is used, then the corresponding entity is populated by the server. ● PROFILE_XXX types will populate the profile field for example with the corresponding profile. ● URL type will populate the image URL ● RESOURCE_NAME will populate the pre-canned resource name.
  • 57. Rendering Images ● Infra code extracts Image URL out of ImageViewModel ● Load into platform specific image view. One Attribute: Regular ImageView Multiple Attributes: GridImageView
  • 58. Performance considerations Entities may repeat multiple times within the same notification causing payload size bloat. Tim’s Profile in ImageViewModel Tim’s Profile in TextViewModel
  • 59. Solution: Response Normalization All canonical entities have a unique ID. Use a JSON API like response format. { “data” : { “Profile”: “profile:123”, ... }, “included”: [ { “id” : “profile:123”, “firstName” : “Tim”, “LastName” : “Jurka”, ... } }, .... ] }
  • 60. Performance considerations (Continued) All fields from the entities may not be used. ImageURL First Name and Last Name
  • 61. Solution: Deco Deco is a LinkedIn framework that allows selective projection and decoration of fields. Profile in TextViewModel ID FirstName LastName Profile in ImageViewModel ID ImageURL Profile in Response ID FirstName LastName ImageURL
  • 63. Improved Developer and Product Velocity 9 new notification types in all of 2016 16 new notification types in May and June 2017
  • 64. API model reduction 42 API models for old UI 6 API models for new UI
  • 65. Code size reduction 15k LOC app and test code for old UI 3k LOC app and test code for new UI
  • 66. Future Direction ● Extend to other pages in Flagship ● Extend to other LinkedIn apps like JobSeeker, Recruiter etc.
  • 67. Out of scope for this talk ● Intricate details of client side consistency management ● Generic Modeling of actions ● Challenges in migrating from the old notifications API to the new one Find us after the talk, and we’re happy to chat about this and more.
  • 68. Q & A ​amodi@linkedin.com ​https://www.linkedin.com/in/modiaditya/ ​ ​Aditya Modi ​kramgopal@linkedin.com ​https://www.linkedin.com/in/karthikrg/ ​ ​ ​Karthik Ramgopal
  • 69. Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ linkedin-api-modeling