SlideShare a Scribd company logo
1 of 14
Download to read offline
PYClientServer
Python powered Client-Server architecture on
compressed JSON channel
Outline
❖ Intro
❖ Requirements
❖ Architecture
❖ Implementation
❖ Tests
❖ Conclusion
Introduction - 1 of 2
❏ A need: seamless integration using a lightweight data
exchange format
❏ JSON is emerging as the modern de-facto standard data format for
services integration
❏ TCP is a must, it is reliable and can be secure
❏ JSON over TCP is a trustable solution
❏ Why compression? JSON strings are naturally verbose,
but less than XML, so
❏ compression can help in reducing the footprint
❏ bandwidth utilisation can be effectively improved
❏ RTT latency benefits from (much more responsiveness)
Introduction - 2 of 2
❏ And, Python? Well, it is an agile main stream
programming language
❏ very well suited for network communication
❏ very well supported
❏ platform-independent (so, portable solutions)
❏ powerful in string/data processing
❏ ...
❏ PYClientServer represents an attempt to implement a
working example of the previously outlined needs
Requirements
❏ Let’s go through the needs introduced
a. services integration over the network
b. seamless lightweight communication
c. effective bandwidth utilisation
d. easy extensibility
e. rapid development
f. working code to extend for enhancements
❏ Let’s summarize as follows
a. A Server offering a data-centric service
b. A Client asking for the service
c. A flexible Data Model offering
❏ marshalling/unmarshalling facility
❏ compression/decompression facility
Architecture
Client Server
TCP
Channel
Decoder Encoder
Process#1
Thread#1
Process#2
Thread#1
File System
1. JSON request
2. File Reading
3. Text
compression
4. Server
response
5. Decompressed
Text
0101010101
{ GET, 100 }
Implementation - 1 of 5
❏ Key implementation aspects concerning the Server
a. it takes advantage of Python’s powerful network library: 1 server
handler in few LoC
b. it receives text-based request and replies providing compressed data
❏ Let’s have a look at the code
class TCPRequestHandler(SocketServer.BaseRequestHandler):
…
try:
print "[TCPRequestHandler][handle] Connection accepted... processing"
# Reading request (assuming a small amount of bytes)
data = self.request.recv(1024).strip()
# Unmarshall the request
request = Request('', 0)
data = request.from_json(data)
…
Implementation - 2 of 5
# Read lines from a text file
resource = []
resource.append(self.__resourcepath)
resource.append(self.__filename)
testfile = open(''.join(resource), 'r')
# Prepare the response data
response = Data(True, [], 0)
list = testfile.readlines()
response.vector = list
response.nrbytes = len(list)
# Marshall JSON representation
json_str = response.to_json()
c_response = self.__compression.compress(json_str)
start = time.time()
self.request.sendall(c_response)
print "[TCPRequestHandler][handle] Bunch of compressed data sent back!"
end = time.time()
if (self.__isdebug):
print "Delivery::Time Elapsed::", str(end - start)
Implementation - 3 of 5
❏ As already seen in the Server code, system Data Model
is very important, because
a. it allows to seamlessly marshall/unmarshall the data
b. it allows to perform compression/decompression, according to the
communication protocol
class Request(object):
def __init__(self, name, code):
self.name = name
self.code = code
def to_json(self):
self.__dict__['name'] = self.name
self.__dict__['code'] = self.code
return json.dumps(self.__dict__, indent=4)
def from_json(self, sting):
dict = json.loads(sting)
self.__dict__ = dict
Implementation - 4 of 5
class Utility(object):
def compress(self, data):
string = str(data)
return zlib.compress(string, zlib.Z_BEST_COMPRESSION)
def decompress(self, data):
string = str(zlib.decompress(data))
return string
❏ Till now, Server and Data Model have been briefly
discussed, but those are only simple snippets of code
❏ To have a look at the full code of Server and Data Model, check the
project out on GitHub.
Implementation - 5 of 5
❏ Client thread is the most simple entity involved in the
scenario sketched on the architecture, in fact, it acts as
follows
❏ send a pure JSON request (Data Model aids in doing that)
❏ upon a reception of server data, it performs the decompression as
dictated by the defined communication protocol
# Request creation
data = Request('GET', 100)
# Client socket binding
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((self.__serverhost, self.__serverport))
# Sending JSON data over the socket
sock.send(data.to_json())
response = self.__receive_data(sock)
# Treating compressed data
result = self.__compression.decompress(response)
data = Data(False, [], 0)
data.from_json(result)
Tests
❏ Hereafter some screenshots captured during a session
test are proposed
Server-side: it is important to consider how the compression reduces
drastically the dimensions (form 4.2MB to 1MB)
Client-Side: in less than 1 second, the data are received. Afterwards, data
are decompressed and the first line of the document is disaplyed
Conclusion - 1 of 2
❏ Architecting the communication protocol for the service
integration as shown in the architectural sketch, brings
several advantages
a. effective bandwidth utilization: the compression reduces the verbosity
b. much more responsiveness: the entire data frame is trasferred in less
than a second
❏ Python network programming is really powerful: with
few lines of code, the application programmer can
define and deploy a working multithreaded service
❏ JSON format is really amazing to work with in Python:
as shown, with few lines of code, the library makes the
serialization and deserialization a pretty easy job
❏ Despite the simplified snippets presented, in the
previous slides
❏ Client, Server and Data Model have been presented as the three main
entities involved by design, but some other interesting features have to
be discovered
❏ System Architecture has been depicted and, as seen, it is simple but
powerful at the same time: there is the reason to believe that that
Architecture might scale very well
❏ If you want to contribute or to have a deeper look at the
code, do not hesitate to check the project out from
GitHub.
Conclusion - 2 of 2

More Related Content

Viewers also liked

K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm ...
K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm ...K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm ...
K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm ...Edureka!
 
Apache Spark & Hadoop : Train-the-trainer
Apache Spark & Hadoop : Train-the-trainerApache Spark & Hadoop : Train-the-trainer
Apache Spark & Hadoop : Train-the-trainerIMC Institute
 
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...Edureka!
 
Big Data in Container; Hadoop Spark in Docker and Mesos
Big Data in Container; Hadoop Spark in Docker and MesosBig Data in Container; Hadoop Spark in Docker and Mesos
Big Data in Container; Hadoop Spark in Docker and MesosHeiko Loewe
 
Logistic regression
Logistic regressionLogistic regression
Logistic regressionsaba khan
 
Hadoop 2.0 Architecture | HDFS Federation | NameNode High Availability |
Hadoop 2.0 Architecture | HDFS Federation | NameNode High Availability | Hadoop 2.0 Architecture | HDFS Federation | NameNode High Availability |
Hadoop 2.0 Architecture | HDFS Federation | NameNode High Availability | Edureka!
 
Transitioning Compute Models: Hadoop MapReduce to Spark
Transitioning Compute Models: Hadoop MapReduce to SparkTransitioning Compute Models: Hadoop MapReduce to Spark
Transitioning Compute Models: Hadoop MapReduce to SparkSlim Baltagi
 
Online Voting System Project File
Online Voting System Project FileOnline Voting System Project File
Online Voting System Project FileNitin Bhasin
 

Viewers also liked (12)

Online Voting System
Online Voting SystemOnline Voting System
Online Voting System
 
Apache Spark & Hadoop
Apache Spark & HadoopApache Spark & Hadoop
Apache Spark & Hadoop
 
K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm ...
K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm ...K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm ...
K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm ...
 
Apache Spark & Hadoop : Train-the-trainer
Apache Spark & Hadoop : Train-the-trainerApache Spark & Hadoop : Train-the-trainer
Apache Spark & Hadoop : Train-the-trainer
 
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
 
Big Data in Container; Hadoop Spark in Docker and Mesos
Big Data in Container; Hadoop Spark in Docker and MesosBig Data in Container; Hadoop Spark in Docker and Mesos
Big Data in Container; Hadoop Spark in Docker and Mesos
 
Logistic Regression Analysis
Logistic Regression AnalysisLogistic Regression Analysis
Logistic Regression Analysis
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 
Hadoop 2.0 Architecture | HDFS Federation | NameNode High Availability |
Hadoop 2.0 Architecture | HDFS Federation | NameNode High Availability | Hadoop 2.0 Architecture | HDFS Federation | NameNode High Availability |
Hadoop 2.0 Architecture | HDFS Federation | NameNode High Availability |
 
Transitioning Compute Models: Hadoop MapReduce to Spark
Transitioning Compute Models: Hadoop MapReduce to SparkTransitioning Compute Models: Hadoop MapReduce to Spark
Transitioning Compute Models: Hadoop MapReduce to Spark
 
Online Voting System Project File
Online Voting System Project FileOnline Voting System Project File
Online Voting System Project File
 
Apache Spark Architecture
Apache Spark ArchitectureApache Spark Architecture
Apache Spark Architecture
 

Recently uploaded

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

PyClientServer: a Python powererd Client-Server Architecture over a compressed JSON/TCP channel

  • 1. PYClientServer Python powered Client-Server architecture on compressed JSON channel
  • 2. Outline ❖ Intro ❖ Requirements ❖ Architecture ❖ Implementation ❖ Tests ❖ Conclusion
  • 3. Introduction - 1 of 2 ❏ A need: seamless integration using a lightweight data exchange format ❏ JSON is emerging as the modern de-facto standard data format for services integration ❏ TCP is a must, it is reliable and can be secure ❏ JSON over TCP is a trustable solution ❏ Why compression? JSON strings are naturally verbose, but less than XML, so ❏ compression can help in reducing the footprint ❏ bandwidth utilisation can be effectively improved ❏ RTT latency benefits from (much more responsiveness)
  • 4. Introduction - 2 of 2 ❏ And, Python? Well, it is an agile main stream programming language ❏ very well suited for network communication ❏ very well supported ❏ platform-independent (so, portable solutions) ❏ powerful in string/data processing ❏ ... ❏ PYClientServer represents an attempt to implement a working example of the previously outlined needs
  • 5. Requirements ❏ Let’s go through the needs introduced a. services integration over the network b. seamless lightweight communication c. effective bandwidth utilisation d. easy extensibility e. rapid development f. working code to extend for enhancements ❏ Let’s summarize as follows a. A Server offering a data-centric service b. A Client asking for the service c. A flexible Data Model offering ❏ marshalling/unmarshalling facility ❏ compression/decompression facility
  • 6. Architecture Client Server TCP Channel Decoder Encoder Process#1 Thread#1 Process#2 Thread#1 File System 1. JSON request 2. File Reading 3. Text compression 4. Server response 5. Decompressed Text 0101010101 { GET, 100 }
  • 7. Implementation - 1 of 5 ❏ Key implementation aspects concerning the Server a. it takes advantage of Python’s powerful network library: 1 server handler in few LoC b. it receives text-based request and replies providing compressed data ❏ Let’s have a look at the code class TCPRequestHandler(SocketServer.BaseRequestHandler): … try: print "[TCPRequestHandler][handle] Connection accepted... processing" # Reading request (assuming a small amount of bytes) data = self.request.recv(1024).strip() # Unmarshall the request request = Request('', 0) data = request.from_json(data) …
  • 8. Implementation - 2 of 5 # Read lines from a text file resource = [] resource.append(self.__resourcepath) resource.append(self.__filename) testfile = open(''.join(resource), 'r') # Prepare the response data response = Data(True, [], 0) list = testfile.readlines() response.vector = list response.nrbytes = len(list) # Marshall JSON representation json_str = response.to_json() c_response = self.__compression.compress(json_str) start = time.time() self.request.sendall(c_response) print "[TCPRequestHandler][handle] Bunch of compressed data sent back!" end = time.time() if (self.__isdebug): print "Delivery::Time Elapsed::", str(end - start)
  • 9. Implementation - 3 of 5 ❏ As already seen in the Server code, system Data Model is very important, because a. it allows to seamlessly marshall/unmarshall the data b. it allows to perform compression/decompression, according to the communication protocol class Request(object): def __init__(self, name, code): self.name = name self.code = code def to_json(self): self.__dict__['name'] = self.name self.__dict__['code'] = self.code return json.dumps(self.__dict__, indent=4) def from_json(self, sting): dict = json.loads(sting) self.__dict__ = dict
  • 10. Implementation - 4 of 5 class Utility(object): def compress(self, data): string = str(data) return zlib.compress(string, zlib.Z_BEST_COMPRESSION) def decompress(self, data): string = str(zlib.decompress(data)) return string ❏ Till now, Server and Data Model have been briefly discussed, but those are only simple snippets of code ❏ To have a look at the full code of Server and Data Model, check the project out on GitHub.
  • 11. Implementation - 5 of 5 ❏ Client thread is the most simple entity involved in the scenario sketched on the architecture, in fact, it acts as follows ❏ send a pure JSON request (Data Model aids in doing that) ❏ upon a reception of server data, it performs the decompression as dictated by the defined communication protocol # Request creation data = Request('GET', 100) # Client socket binding sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((self.__serverhost, self.__serverport)) # Sending JSON data over the socket sock.send(data.to_json()) response = self.__receive_data(sock) # Treating compressed data result = self.__compression.decompress(response) data = Data(False, [], 0) data.from_json(result)
  • 12. Tests ❏ Hereafter some screenshots captured during a session test are proposed Server-side: it is important to consider how the compression reduces drastically the dimensions (form 4.2MB to 1MB) Client-Side: in less than 1 second, the data are received. Afterwards, data are decompressed and the first line of the document is disaplyed
  • 13. Conclusion - 1 of 2 ❏ Architecting the communication protocol for the service integration as shown in the architectural sketch, brings several advantages a. effective bandwidth utilization: the compression reduces the verbosity b. much more responsiveness: the entire data frame is trasferred in less than a second ❏ Python network programming is really powerful: with few lines of code, the application programmer can define and deploy a working multithreaded service ❏ JSON format is really amazing to work with in Python: as shown, with few lines of code, the library makes the serialization and deserialization a pretty easy job
  • 14. ❏ Despite the simplified snippets presented, in the previous slides ❏ Client, Server and Data Model have been presented as the three main entities involved by design, but some other interesting features have to be discovered ❏ System Architecture has been depicted and, as seen, it is simple but powerful at the same time: there is the reason to believe that that Architecture might scale very well ❏ If you want to contribute or to have a deeper look at the code, do not hesitate to check the project out from GitHub. Conclusion - 2 of 2