3. Solutions ??
SOAP : Do we really need to parse so much XML ?
COM : Works only for windows
Protocol Buffers:
Does not support RPC out of the box
Mainly focussed on serialization and deserialization
MessagePack:
Well, It wasn’t popular enough when the system was designed.
07/07/11
5. Thrift
Remote Procedural Call (RPC) Framework for developing scalable cross
language services.
Developed by Facebook, Open sourced in April 2007
Entered Apache Inbubation in May 2008
Current Version 0.6
Supported Languages : C++, Java, Python, PHP, Ruby, Erlang, Perl,
Haskell, C#, Cocoa, JavaScript, Node.js,
Smalltalk, Squeak, OCaml
07/07/11
6. Components
Type System
Generic Type System compatible with all languages.
Transport Layer
Actual data transfer over stream sockets/HTTP etc.
Protocol Layer
Encoding/Decoding of data types
Processors
Encapsulates logic of reading/writing to input/output streams
Server
Wrapper over all above layers for the server end
07/07/11
7. Type System
Define your data types in a Thrift Interface Description File
Base Types:
bool
byte
Integers: i16, i32, i64
double
string
Structs : C style structures
Containers: List, Set, Map
Exceptions: Basically structs
Services: Interfaces defining the remote methods. Equivalent to an
abstract class
07/07/11
8. Transport Layer
Abstracts out the logic of reading/writing over the communication
layer through Interfaces
Decouples the remaining system from nitty-gritty of raw data transfer
TTransport Interface :
open, close, isOpen, read, write, flush
TServerTransport Interface:
open, listen, accept, close
Available Implementation :
TSocket, TFileTransport, TFramedTransport,
TBufferedTransport, TServerSocket etc
07/07/11
9. Protocol Layer
Abstracts out the serialization and deserialization of data types
Exposes read/write methods for all data types
Implementations:
Binary
Compact
JSON
Plain Text, XML
07/07/11
10. Processor and Server
TProcesser interface handles the reading and writing of data
through TProtocol objects.
Invokes the user implemented handlers for remote methods
Server:
Encapsulates all the above layers:
Creates transport
Creates protocols for the transport
Creates a processor based on the input/output protocols
Listen for incoming connections and pass them to the
processor
TSimpleServer, TThreadedServer, TThreadPoolServer
07/07/11
12. Thrift at Capillary
Dynamic Vouchers
LAMP based server
Java Based Business Rule Engine
Over 1000 rules to be processed on every transaction
Prioritization/Selection of the vouchers generated
Thrift for PHP-JAVA communication.
TSocket
TBinary
TThreadedServer
25-30 RPS during peak time
07/07/11
13. Thrift at Capillary
SMS Engine:
Transactional SMS:
“Hello Mr. Sharma, thanks for shopping at our store today. You have been
awarded 100 points. “
PHP web-service / Java based sms sending engine.
Thrift for PHP-Java communication
Promotional:
Sends out personalized SMS to customers
“Hello Mr Shahrukh Khan, its been 3 months since you visited
our MG Road outlet. Hoping to see you soon !!”
On average ~1.5-2 MM SMS per day
Java based system for message generation/template replacement
Java based system to send messages to gateway.
Java – Java communication over thrift.
07/07/11
17. Which of the following languages Thrift does not
support ?
1) SmallTalk
2) Squeak
3) C
4) Objective-C
07/07/11
18. Which interface implementation is responsible for
managing incoming connections on the Server in Thrift ?
1) TProtocol
2) TProcesser
3) TTransport
4) TServer
07/07/11
19. Which of the following projects is/are using Thrift internally?
1) HBase
2) HyperTable
3) Voldemort
4) Cassandra
07/07/11
20. We are Hiring !!!
career-tech@capillary.co.in
piyush.goel@capillary.co.in
http://capillary.co.in
07/07/11