Consuming HTTP Services in Python Transcripts
Chapter: The service landscape
Lecture: Service type: Raw sockets

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's begin our exploration of services and consuming services in Python by taking a survey of the various types of services
0:08 that we might encounter out there in the world. We are going to do this by focusing on the lowest level services and moving up in abstractions.
0:17 So the lowest level service that we could have, the way that we could talk to the service
0:22 is with using just raw network sockets and just sending bytes on the wire. So we would open up a socket with bidirectional communication
0:31 and we would send 00101 over the service and it knows what that means, they will say great, 1101 and so on.
0:38 This is the fastest, lowest level, lowest latency way to interact with services, so there are benefits here, it's super fast and it's responsive
0:46 because we can actually send custom messages tailor made for the types of messages that these two apps exchange,
0:54 it can be extremely low overhead in terms of bandwidth, do you need to send four bytes as an integer?
1:00 Well, maybe you just send four bytes and it just knows an integer is coming, so literally, there is no wasted sort of packaging on the messages,
1:06 so why aren't all of our services like this, well, there is usually way more drawbacks than there are benefits.
1:13 many time this means there is special protocols, you have some app,
1:18 in order to talk to it you have to use an entirely unique protocol just to speak to that. And often those don't have standards around them,
1:26 often those are brittle and just not easy to work with, not easy to get started. Another problem is proxies and firewalls, especially firewalls.
1:35 So packet inspecting firewalls really hate letting traffic out of the firewall, if it's some sort of binary blob.
1:45 They would much rather see some kind of HTTP traffic where they can inspect it and make sure that it's all legit and good.
1:50 Also, these often run on non standard ports and there can be problems with firewalls as well.
1:56 There are some platform specific issues you run into as well, like just above raw sockets, but still more or less sending raw bytes
2:03 are things like on the Windows platform DCOM or .NET remoting, on Java we have RMI, remote method invocation
2:13 and these might be sending like in memory representations of some kind of object from one .NET app to a .NET server for example,
2:20 and that means it's extremely fragile and really inaccessible to Python or Javascript or other things like that,
2:27 it's like you have to basically have the same technology on both sides. And also, if you look at the network traffic, can you make sense of it?
2:34 I can't, not usually anyway, it's very hard to read just binary blobs, it's also hard to debug if things go wrong because you cannot read it,
2:41 okay, but we do have low latency, low bandwidth, high speed raw sockets, and that is possible of course in Python.


Talk Python's Mastodon Michael Kennedy's Mastodon