SlideShare a Scribd company logo
Building scalable and language-independent Java services using Apache Thrift Sanjoy Singh
Sanjoy Singh Over 8 years of industry experience Senior Team Lead, Talentica Software Software Engineer, OEM Technology Instruments Education B Tech (CS), REC Jalandhar
Scalability ?? Design/Program is said to scale …  -  if it is suitably efficient and practical when applied to large situations Measures Load Functional
Agenda Key Components/Challenges for Cross Language Interactions Various System for Cross Language Interactions Dive Into Apache Thrift Principle Of Operation Example Thrift Stack Versioning Why to use Thrift. Limitations? Quick Code Walkthrough
LAMP  +  Services High-Level Goal: Enable transparent interaction between these. … and some others too.
High Level Goals ! Transparent Interaction between multiple programming languages. Maintain Right balance between Performance Ease and speed of development Availability of existing libraries etc
Simple Distributed Architecture Waiting for requests (known location, known port) Communication protocol, Data format Sending requests, getting results Basic questions are: What kind of protocol to use, and what data to transmit? What to do with requests on the server side?
Key  Components/Challenges  ! Type system Transport system Protocol system Versioning Processor Performance No problem can stand the  assault  of sustained thinking.
Hasn’t this been done before?  (yes.) ‏ SOAP CORBA COM Pillar Protocol Buffers etc
Should we pick up one of those? (not sure) ‏ SOAP XML, XML, and more XML CORBA Over designed and Heavyweight COM Embraced mainly in Windows Client Software Pillar Slick! But no versioning/abstraction. Protocol Buffers etc Closed source Google deliciousness
Decision Time ! As a developer, what are you looking for? Be Patient, I have something for you in the subsequent slides !!
Solution Apache  Thrift Software framework for scalable cross-language services development.
Apache Thrift - Introduction Originally developed at Facebook  Open sourced in April 2007 Easy exchange of data  Cross language serialization with  minimal overhead Thrift tools can generate code for C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, Smalltalk and OCaml
Lets Dive In..
Principle Of Operation Thrift Code Generator Tool (written in C++) Create a thrift file eg demo.thrift Define Data types and Service interfaces Build Thrift platform files Demo.php Demo.java Demo.py Demo.cpp Create Server/Client App Run the Server Server implements Services and Client calls them
Thrift Cares About Type Definitions Service Definitions Thrift Doesn’t Care About Wire Protocol (internal XML...) Transport (HTTP? Sockets? Whatevz!) Programming Languages
Enough Banter. Show Us the Goodz. // Include other thrift files include "shared.thrift“ namespace java calculator enum Operation {  // define enums ADD = 1, SUBTRACT = 2, MULTIPLY = 3, DIVIDE = 4 } struct Work { // complex data structures 1: i32 num1 = 0, 2: i32 num2, 3: Operation op, 4: optional string comment, }
Enough Banter. Show Us the Goodz. // Exception exception InvalidOperation { 1: i32 what, 2: string why } // Service  service Calculator extends shared.SharedService { void ping(), i32 add(1:i32 num1, 2:i32 num2), i32 calculate(1:i32 logid, 2:Work w) throws (1:InvalidOperation ouch), oneway void zip() }
Enough Banter. Show Us the Goodz . // Include other thrift files include "shared.thrift“ namespace java calculator enum Operation {  // define enums ADD = 1, SUBTRACT = 2, MULTIPLY = 3, DIVIDE = 4 } struct Work { // complex data structures 1: i32 num1 = 0, 2: i32 num2, 3: Operation op, 4: optional string comment, } // Exception exception InvalidOperation { 1: i32 what, 2: string why } // Service  service Calculator extends  shared.SharedService { void ping(), i32 add(1:i32 num1, 2:i32 num2), i32 calculate(1:i32 logid, 2:Work w)  throws (1:InvalidOperation ouch), oneway void zip() }
What DOES that do? Generates definitions for all the types in each language Generates Client and Server interfaces for each language What DOESNT that do? Anything to do with sockets Anything to do with serialization
Magically Generated Files gen-java/calculatordemo Calculator.java InvalidOperation.java Operation.java Work.java gen-php/ Calculator.php calculator_types gen-py/ ttypes.py Calculator.py Calculator-remote
Create a system that is abstracted in a systematic way, such that developers can easily extend it to suit their needs and function in custom environments. Thrift Philosophy
Structs don’t have any code to do with serialization or sockets, etc.  But they know how to read and write themselves… How does that work?
The Thrift Stack T he Thrift stack is a common class hierarchy implemented in each language that abstracts out the tricky details of protocol encoding and network communication. It provides a simple interface for generated code to use. There are two key interfaces: TTransport De-coupled the transport layer from Code Generation Layer. Provides read() and write(), with a set of other helpers like open(), close(), etc. Implementation -  TSocket, TFileTransport, TBufferedTransport, TFramedTransport, TMemoryBuffer. TProtocol Separate Data Structure from Transport representation. Provides the ability to read and write various types of data, i.e. readI32(), writeString(), etc. Supports Bi-directional sequenced messaging and encoding of base types, container and  struts.
The Thrift Stack Object write() TTransport TProtocol TTransport TProtocol Object read() Information Flow!
Versioning (applications change, not protocols!) What happens when definitions change? Struct needs a new member Function needs a new argument No Problem! We’ve got Field Identifiers! Example: struct Work { 1:  i32 num1 = 0, 2:  i32 num2, 3:  Operation op, 4:  optional string comment, }
Versioning  - Case Analysis Add a Field New Client, Old Server Server sees a field id that it doesn’t recognize, and safely ignores it. Old Client, New Server Server doesn’t see the field id it expects. Leaves it unset in object, server implementation can properly handle Remove a Field New Client, Old Server Server doesn’t see field it expects. Analogous to above. Old Client, New Server Old client sends deprecated field. Server politely ignore it. Analogous to the top case.
Why to use Thrift … Less time wasted by individual developers No duplicated networking and protocol code less time dealing with boilerplate stuff Write your client and server in about 5 minutes Less maintenance One networking code base that needs maintenance Fix bugs once, rather than repeatedly in every server Division of labour Work on high-performance servers separate from applications Common toolkit Code reuse and shared tools
Why to use Thrift … Cross-language serialization with lower overhead than alternatives such as SOAP due to use of binary format A lean and clean library. No framework to code to. No XML configuration files The language bindings feel natural. For example Java uses ArrayList<String>. C++ uses std::vector<std::string> The application-level wire format and the serialization-level wire format are cleanly separated. They can be modified independently
Why to use Thrift … The predefined serialization styles include: binary, HTTP-friendly and compact binary. Soft versioning of the protocol.  No build dependencies or non-standard software. No mix of incompatible software licenses.
Limitations / Non-Features Is struct inheritance/polymorphism supported? No, it isn’t Can I overload service methods? Nope. Method names must be unique.  Heterogeneous containers Not supported Is there any enough documentation on Thrift development? I think this is one weak area.
Steps/Code Walkthrough (Lets build the example described earlier)
Some Real Time Example PHP based  Web App Thrift PHP Lib Search Service (implemented in C++
Why Should I not try this? Guess the answer? Answer: Please do let me know at  [email_address] Skpe_id/Gtalk_id : sanjoy_17 /sanjoy17
References http://incubator.apache.org/thrift/ http://incubator.apache.org/thrift/static/thrift-20070401.pdf
Thanks !!!
Ad

More Related Content

What's hot (20)

.net framework
.net framework.net framework
.net framework
Ram Sagar Mourya
 
Overview Of .Net 4.0 Sanjay Vyas
Overview Of .Net 4.0   Sanjay VyasOverview Of .Net 4.0   Sanjay Vyas
Overview Of .Net 4.0 Sanjay Vyas
rsnarayanan
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side Notifications
Arnaud Bouchez
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet Introduction
Wei Sun
 
Net framework
Net frameworkNet framework
Net framework
jhsri
 
Livecode widget course
Livecode widget courseLivecode widget course
Livecode widget course
crazyaxe
 
Overview of microsoft dot net platforms
Overview of microsoft dot net platformsOverview of microsoft dot net platforms
Overview of microsoft dot net platforms
Abhijit B.
 
.Net overview
.Net overview.Net overview
.Net overview
teach4uin
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
Siraj Memon
 
Components of .NET Framework
Components of .NET FrameworkComponents of .NET Framework
Components of .NET Framework
Roshith S Pai
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
Doncho Minkov
 
Nakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishNakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - English
Svetlin Nakov
 
Web developer tools
Web developer toolsWeb developer tools
Web developer tools
Om shanti Web solutions
 
Migrating To Visual Studio 2008 & .Net Framework 3.5
Migrating To Visual Studio 2008 & .Net Framework 3.5Migrating To Visual Studio 2008 & .Net Framework 3.5
Migrating To Visual Studio 2008 & .Net Framework 3.5
Jeff Blankenburg
 
Create Your Own Language
Create Your Own LanguageCreate Your Own Language
Create Your Own Language
Hamidreza Soleimani
 
Dotnet basics
Dotnet basicsDotnet basics
Dotnet basics
Mir Majid
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - Introduction
Randy Connolly
 
LIL Presentation
LIL PresentationLIL Presentation
LIL Presentation
badsectoracula
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Maarten Balliauw
 
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
citizenmatt
 
Overview Of .Net 4.0 Sanjay Vyas
Overview Of .Net 4.0   Sanjay VyasOverview Of .Net 4.0   Sanjay Vyas
Overview Of .Net 4.0 Sanjay Vyas
rsnarayanan
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side Notifications
Arnaud Bouchez
 
DotNet Introduction
DotNet IntroductionDotNet Introduction
DotNet Introduction
Wei Sun
 
Net framework
Net frameworkNet framework
Net framework
jhsri
 
Livecode widget course
Livecode widget courseLivecode widget course
Livecode widget course
crazyaxe
 
Overview of microsoft dot net platforms
Overview of microsoft dot net platformsOverview of microsoft dot net platforms
Overview of microsoft dot net platforms
Abhijit B.
 
.Net overview
.Net overview.Net overview
.Net overview
teach4uin
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
Siraj Memon
 
Components of .NET Framework
Components of .NET FrameworkComponents of .NET Framework
Components of .NET Framework
Roshith S Pai
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
Doncho Minkov
 
Nakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishNakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - English
Svetlin Nakov
 
Migrating To Visual Studio 2008 & .Net Framework 3.5
Migrating To Visual Studio 2008 & .Net Framework 3.5Migrating To Visual Studio 2008 & .Net Framework 3.5
Migrating To Visual Studio 2008 & .Net Framework 3.5
Jeff Blankenburg
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - Introduction
Randy Connolly
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Maarten Balliauw
 
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
citizenmatt
 

Similar to Building scalable and language independent java services using apache thrift (20)

Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...
IndicThreads
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
Maarten Balliauw
 
.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi
Spiffy
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
Maarten Balliauw
 
Programming
Programming Programming
Programming
Kapcom Rawal
 
thrift-20070401
thrift-20070401thrift-20070401
thrift-20070401
Hiroshi Ono
 
Open source Technology
Open source TechnologyOpen source Technology
Open source Technology
Amardeep Vishwakarma
 
Introduction to .net
Introduction to .netIntroduction to .net
Introduction to .net
Karthika Parthasarathy
 
Introduction to Thrift
Introduction to ThriftIntroduction to Thrift
Introduction to Thrift
Dvir Volk
 
Dev381.Pp
Dev381.PpDev381.Pp
Dev381.Pp
Severus Prime
 
Socket programming-in-python
Socket programming-in-pythonSocket programming-in-python
Socket programming-in-python
Yuvaraja Ravi
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
Marco Parenzan
 
javaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
javaeanjjisjejrehurfhjhjfeauojksfjdi.pptjavaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
javaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
eraqhuzay69
 
dot NET Framework
dot NET Frameworkdot NET Framework
dot NET Framework
Roy Antony Arnold G
 
CocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIsCocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIs
Tim Burks
 
Inside.Net
Inside.NetInside.Net
Inside.Net
Ganesh Samarthyam
 
Net Fundamentals
Net FundamentalsNet Fundamentals
Net Fundamentals
Ali Taki
 
Visual studio
Visual studioVisual studio
Visual studio
anupathak17jul
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
KPDDRAVIDIAN
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascript
Andrei Sebastian Cîmpean
 
Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...
IndicThreads
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
Maarten Balliauw
 
.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi
Spiffy
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
Maarten Balliauw
 
Introduction to Thrift
Introduction to ThriftIntroduction to Thrift
Introduction to Thrift
Dvir Volk
 
Socket programming-in-python
Socket programming-in-pythonSocket programming-in-python
Socket programming-in-python
Yuvaraja Ravi
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
Marco Parenzan
 
javaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
javaeanjjisjejrehurfhjhjfeauojksfjdi.pptjavaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
javaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
eraqhuzay69
 
CocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIsCocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIs
Tim Burks
 
Net Fundamentals
Net FundamentalsNet Fundamentals
Net Fundamentals
Ali Taki
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascript
Andrei Sebastian Cîmpean
 
Ad

More from Talentica Software (20)

Webpack/Parcel: What’s Happening Behind the React App?
Webpack/Parcel: What’s Happening Behind the React App?Webpack/Parcel: What’s Happening Behind the React App?
Webpack/Parcel: What’s Happening Behind the React App?
Talentica Software
 
Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to Advanced
Talentica Software
 
Web 3.0
Web 3.0Web 3.0
Web 3.0
Talentica Software
 
Remix
RemixRemix
Remix
Talentica Software
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
Talentica Software
 
Nodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design PatternNodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design Pattern
Talentica Software
 
Node js Chapter-2
Node js Chapter-2Node js Chapter-2
Node js Chapter-2
Talentica Software
 
Node.js Chapter1
Node.js Chapter1Node.js Chapter1
Node.js Chapter1
Talentica Software
 
Micro Frontends
Micro FrontendsMicro Frontends
Micro Frontends
Talentica Software
 
Test Policy and Practices
Test Policy and PracticesTest Policy and Practices
Test Policy and Practices
Talentica Software
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
Talentica Software
 
Setting Up Development Environment For Google App Engine & Python | Talentica
Setting Up Development Environment For Google App Engine & Python | TalenticaSetting Up Development Environment For Google App Engine & Python | Talentica
Setting Up Development Environment For Google App Engine & Python | Talentica
Talentica Software
 
Connected World in android - Local data sharing and service discovery
Connected World in android - Local data sharing and service discoveryConnected World in android - Local data sharing and service discovery
Connected World in android - Local data sharing and service discovery
Talentica Software
 
Mobile App Monetization - Ecosystem & Emerging Trends
Mobile App Monetization - Ecosystem & Emerging TrendsMobile App Monetization - Ecosystem & Emerging Trends
Mobile App Monetization - Ecosystem & Emerging Trends
Talentica Software
 
Android Media Player Development
Android Media Player DevelopmentAndroid Media Player Development
Android Media Player Development
Talentica Software
 
Cross Platform Mobile Technologies
Cross Platform Mobile TechnologiesCross Platform Mobile Technologies
Cross Platform Mobile Technologies
Talentica Software
 
Big Data Technologies - Hadoop
Big Data Technologies - HadoopBig Data Technologies - Hadoop
Big Data Technologies - Hadoop
Talentica Software
 
Big Data – Are You Ready?
Big Data – Are You Ready?Big Data – Are You Ready?
Big Data – Are You Ready?
Talentica Software
 
Legacy modernization
Legacy modernizationLegacy modernization
Legacy modernization
Talentica Software
 
Continous Integration: A Case Study
Continous Integration: A Case StudyContinous Integration: A Case Study
Continous Integration: A Case Study
Talentica Software
 
Webpack/Parcel: What’s Happening Behind the React App?
Webpack/Parcel: What’s Happening Behind the React App?Webpack/Parcel: What’s Happening Behind the React App?
Webpack/Parcel: What’s Happening Behind the React App?
Talentica Software
 
Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to Advanced
Talentica Software
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
Talentica Software
 
Nodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design PatternNodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design Pattern
Talentica Software
 
Setting Up Development Environment For Google App Engine & Python | Talentica
Setting Up Development Environment For Google App Engine & Python | TalenticaSetting Up Development Environment For Google App Engine & Python | Talentica
Setting Up Development Environment For Google App Engine & Python | Talentica
Talentica Software
 
Connected World in android - Local data sharing and service discovery
Connected World in android - Local data sharing and service discoveryConnected World in android - Local data sharing and service discovery
Connected World in android - Local data sharing and service discovery
Talentica Software
 
Mobile App Monetization - Ecosystem & Emerging Trends
Mobile App Monetization - Ecosystem & Emerging TrendsMobile App Monetization - Ecosystem & Emerging Trends
Mobile App Monetization - Ecosystem & Emerging Trends
Talentica Software
 
Android Media Player Development
Android Media Player DevelopmentAndroid Media Player Development
Android Media Player Development
Talentica Software
 
Cross Platform Mobile Technologies
Cross Platform Mobile TechnologiesCross Platform Mobile Technologies
Cross Platform Mobile Technologies
Talentica Software
 
Big Data Technologies - Hadoop
Big Data Technologies - HadoopBig Data Technologies - Hadoop
Big Data Technologies - Hadoop
Talentica Software
 
Continous Integration: A Case Study
Continous Integration: A Case StudyContinous Integration: A Case Study
Continous Integration: A Case Study
Talentica Software
 
Ad

Recently uploaded (20)

Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Social Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTechSocial Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTech
Steve Jonas
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Social Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTechSocial Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTech
Steve Jonas
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 

Building scalable and language independent java services using apache thrift

  • 1. Building scalable and language-independent Java services using Apache Thrift Sanjoy Singh
  • 2. Sanjoy Singh Over 8 years of industry experience Senior Team Lead, Talentica Software Software Engineer, OEM Technology Instruments Education B Tech (CS), REC Jalandhar
  • 3. Scalability ?? Design/Program is said to scale … - if it is suitably efficient and practical when applied to large situations Measures Load Functional
  • 4. Agenda Key Components/Challenges for Cross Language Interactions Various System for Cross Language Interactions Dive Into Apache Thrift Principle Of Operation Example Thrift Stack Versioning Why to use Thrift. Limitations? Quick Code Walkthrough
  • 5. LAMP + Services High-Level Goal: Enable transparent interaction between these. … and some others too.
  • 6. High Level Goals ! Transparent Interaction between multiple programming languages. Maintain Right balance between Performance Ease and speed of development Availability of existing libraries etc
  • 7. Simple Distributed Architecture Waiting for requests (known location, known port) Communication protocol, Data format Sending requests, getting results Basic questions are: What kind of protocol to use, and what data to transmit? What to do with requests on the server side?
  • 8. Key Components/Challenges ! Type system Transport system Protocol system Versioning Processor Performance No problem can stand the assault of sustained thinking.
  • 9. Hasn’t this been done before? (yes.) ‏ SOAP CORBA COM Pillar Protocol Buffers etc
  • 10. Should we pick up one of those? (not sure) ‏ SOAP XML, XML, and more XML CORBA Over designed and Heavyweight COM Embraced mainly in Windows Client Software Pillar Slick! But no versioning/abstraction. Protocol Buffers etc Closed source Google deliciousness
  • 11. Decision Time ! As a developer, what are you looking for? Be Patient, I have something for you in the subsequent slides !!
  • 12. Solution Apache Thrift Software framework for scalable cross-language services development.
  • 13. Apache Thrift - Introduction Originally developed at Facebook Open sourced in April 2007 Easy exchange of data Cross language serialization with minimal overhead Thrift tools can generate code for C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, Smalltalk and OCaml
  • 15. Principle Of Operation Thrift Code Generator Tool (written in C++) Create a thrift file eg demo.thrift Define Data types and Service interfaces Build Thrift platform files Demo.php Demo.java Demo.py Demo.cpp Create Server/Client App Run the Server Server implements Services and Client calls them
  • 16. Thrift Cares About Type Definitions Service Definitions Thrift Doesn’t Care About Wire Protocol (internal XML...) Transport (HTTP? Sockets? Whatevz!) Programming Languages
  • 17. Enough Banter. Show Us the Goodz. // Include other thrift files include &quot;shared.thrift“ namespace java calculator enum Operation { // define enums ADD = 1, SUBTRACT = 2, MULTIPLY = 3, DIVIDE = 4 } struct Work { // complex data structures 1: i32 num1 = 0, 2: i32 num2, 3: Operation op, 4: optional string comment, }
  • 18. Enough Banter. Show Us the Goodz. // Exception exception InvalidOperation { 1: i32 what, 2: string why } // Service service Calculator extends shared.SharedService { void ping(), i32 add(1:i32 num1, 2:i32 num2), i32 calculate(1:i32 logid, 2:Work w) throws (1:InvalidOperation ouch), oneway void zip() }
  • 19. Enough Banter. Show Us the Goodz . // Include other thrift files include &quot;shared.thrift“ namespace java calculator enum Operation { // define enums ADD = 1, SUBTRACT = 2, MULTIPLY = 3, DIVIDE = 4 } struct Work { // complex data structures 1: i32 num1 = 0, 2: i32 num2, 3: Operation op, 4: optional string comment, } // Exception exception InvalidOperation { 1: i32 what, 2: string why } // Service service Calculator extends shared.SharedService { void ping(), i32 add(1:i32 num1, 2:i32 num2), i32 calculate(1:i32 logid, 2:Work w) throws (1:InvalidOperation ouch), oneway void zip() }
  • 20. What DOES that do? Generates definitions for all the types in each language Generates Client and Server interfaces for each language What DOESNT that do? Anything to do with sockets Anything to do with serialization
  • 21. Magically Generated Files gen-java/calculatordemo Calculator.java InvalidOperation.java Operation.java Work.java gen-php/ Calculator.php calculator_types gen-py/ ttypes.py Calculator.py Calculator-remote
  • 22. Create a system that is abstracted in a systematic way, such that developers can easily extend it to suit their needs and function in custom environments. Thrift Philosophy
  • 23. Structs don’t have any code to do with serialization or sockets, etc. But they know how to read and write themselves… How does that work?
  • 24. The Thrift Stack T he Thrift stack is a common class hierarchy implemented in each language that abstracts out the tricky details of protocol encoding and network communication. It provides a simple interface for generated code to use. There are two key interfaces: TTransport De-coupled the transport layer from Code Generation Layer. Provides read() and write(), with a set of other helpers like open(), close(), etc. Implementation - TSocket, TFileTransport, TBufferedTransport, TFramedTransport, TMemoryBuffer. TProtocol Separate Data Structure from Transport representation. Provides the ability to read and write various types of data, i.e. readI32(), writeString(), etc. Supports Bi-directional sequenced messaging and encoding of base types, container and struts.
  • 25. The Thrift Stack Object write() TTransport TProtocol TTransport TProtocol Object read() Information Flow!
  • 26. Versioning (applications change, not protocols!) What happens when definitions change? Struct needs a new member Function needs a new argument No Problem! We’ve got Field Identifiers! Example: struct Work { 1: i32 num1 = 0, 2: i32 num2, 3: Operation op, 4: optional string comment, }
  • 27. Versioning - Case Analysis Add a Field New Client, Old Server Server sees a field id that it doesn’t recognize, and safely ignores it. Old Client, New Server Server doesn’t see the field id it expects. Leaves it unset in object, server implementation can properly handle Remove a Field New Client, Old Server Server doesn’t see field it expects. Analogous to above. Old Client, New Server Old client sends deprecated field. Server politely ignore it. Analogous to the top case.
  • 28. Why to use Thrift … Less time wasted by individual developers No duplicated networking and protocol code less time dealing with boilerplate stuff Write your client and server in about 5 minutes Less maintenance One networking code base that needs maintenance Fix bugs once, rather than repeatedly in every server Division of labour Work on high-performance servers separate from applications Common toolkit Code reuse and shared tools
  • 29. Why to use Thrift … Cross-language serialization with lower overhead than alternatives such as SOAP due to use of binary format A lean and clean library. No framework to code to. No XML configuration files The language bindings feel natural. For example Java uses ArrayList<String>. C++ uses std::vector<std::string> The application-level wire format and the serialization-level wire format are cleanly separated. They can be modified independently
  • 30. Why to use Thrift … The predefined serialization styles include: binary, HTTP-friendly and compact binary. Soft versioning of the protocol. No build dependencies or non-standard software. No mix of incompatible software licenses.
  • 31. Limitations / Non-Features Is struct inheritance/polymorphism supported? No, it isn’t Can I overload service methods? Nope. Method names must be unique. Heterogeneous containers Not supported Is there any enough documentation on Thrift development? I think this is one weak area.
  • 32. Steps/Code Walkthrough (Lets build the example described earlier)
  • 33. Some Real Time Example PHP based Web App Thrift PHP Lib Search Service (implemented in C++
  • 34. Why Should I not try this? Guess the answer? Answer: Please do let me know at [email_address] Skpe_id/Gtalk_id : sanjoy_17 /sanjoy17

Editor's Notes

  • #15: First of all, in *.thrift file you declare objects and procedures, that you would like to interchange between applications written in different languages. Then, using thrift tool, you build Thrift platform files for programming languages of your choice. Most important step is to create server and client applications, using code generated in the previous step. Server application should implement procedures declared in the thrift file, while client should call them. Thrift itself takes care about creating transport classes, defining objects, etc. so your responsibility is only to use them in your code. Last, but not least :) is to run your server. Then, using client script, you can perform actions using previously defined objects and methods.