Networking with servers



Different devices and computers can be linked together through a router. A router is a device that directs data packets across the network. It assigns an IP address to every device connected to it. This address is unique within the network and hence it is called local IP



In order for a computer to act as a server, it should run a program that listens on one of it's network ports. For eg, if a computer with local IP 192.168.0.2 is running a program that runs some complex computations and listens on port 8005, then any other device in the network can access this program by addressing 192.168.0.2:8005

The data transmission is managed by network protocols like HTTP, Websockets, FTP, SSH. The server should unpack the received data according to relavant protocol and convert it to a form that can be processed by the programming language of your application. Almost all our needs under the scope of our study can be achieved with HTTP or Websockets, each of which has a set of well-maintained libraries.For HTTP, the program that forwards HTTP requests to web applications or frameworks (eg Django) are called Web Server Gateway Interface (eg Gunicorn, Mod WSGI)



Django
Django is a production grade, open source python web framework which forms the main link to our ML programs. Django can interfaces with any kind of database and makes management of webpages or APIs easy. Without a web framework, it would be extremely time consuming to build such applications.

Nginx
Several servers can run in a single machine. For eg, we may have one application for face recognigition, another application for pose estimation and yet another one for music recommendation all running in one machine, but in isolated environments (Docker). To parallelize request handling to make our machine process concurrently as many requests as possible, we use another reverse proxy server Nginx (derieved from the word Engine X)



Other web development stacks
One can also use Apache web server instead of Nginx. But for our usecases, Nginx is cited to be more efficient (This scenario may change in the future). People in the IT world generally use different terminologies to communicate the server stack they use. For eg,


For this study, I will be sticking to LEMP or LEPP. May be I ll touch upon Apache just to for performance tests. Nevertheless, if you can work on one stack, the others should just be a matter of adapting.

Processing requests from internet
Any device outside the Local Area Network (LAN) can access the server only through the gateway, which has a globally unique public IP address. We should configure our modem to forward the required ports to a host machine. Through this machine, we can indirectly access other devices in the network. Otherwise, we can also configure the modem to forward a port separately to each device (this is rarely done and it is not secure).



If you are using a private Internet service provider (ISP), they might block some of your WAN ports. Moreover, you will be assigned only a dynamic public IP, which keeps changing. That means, when you map a domain name to your IP, you have to make sure that it is updated in regular intervals. I have described all these scenarios in the modules.

Sometimes, ISP does not even provide you a public IP! Because of shortage of IPv4 addresses, you will be sharing your public IP with other people. In such cases, your modem will have an IP assigned in RFC 1918 address space and you will have to talk with your ISP to forward a set of ports to your modem.


Go back Modules