What is a server communication?
A communications server is a computing system platform that is used for various network communication applications and allows vendors to add multiple values at different levels of architecture.
As developers we always do client-server communication in our daily development life, but do you know What are the factors you should consider while communication.
1. It is used to limit traffic on our network, let’s say we have a login API and it is configured to limit 10 request/minute over the same IP. If a user tries it more than 10 times then an error will be generated. This feature helps to increase security such as DDOS attacks
2. This can be done in the following ways
a. User Rate Limit
b. Geographic Rate Limit
c. Server Rate Limit
It always depends on the application use case
1. Eager Loading: This can be done if you need each and every entity as per the use case then there is no way to implement Lazy Loading.
2. Lazy Loading: This can be done if your application requires only top-level entities and other details will be requested as per the users choice later, This technique is useful to reduce server load.
It is our responsibility to protect users data and making sure that no 3rd party can access that info without our permission, which can be done with the help of Authorization header. But what it is the Authentication and Authorization
1. Authorization: Authorization is when a user has rights to access some sort of information.
2. Authentication: Authentication means it proves who you are, where server knows about you.
3. Here is a way to authenticate a user
a. HTTP Basic Authentication
b. API Keys
4. It depends on the applications use case to select which is the best method and will fit our use case
Security of sensitive user data
Security of user’s data which transfers over an open communication channel is very important. Security of data may depend on specifications of application use case. If we store data on the server in plain text format then it will be directly accessible by 3rd party user in case of server crack or man in the middle attack. The most secure way to communicate with the server by using end to end encryption method, where the client sends data to a server in an encrypted format and vice versa.
As an application grows, data tables of our application also change. So to support backward compatibility we need to manage versions, so when to update version
1. Major Change
2. Minor Change
3. This can be achieved by using the following ways
a. URI versioning
b. Header versioning
Nowadays most of the apps in some way uses real-time communication, let say any chat application. So how can we achieve this, what are the ways
1. Polling is when a client makes request continuously with server and server returns data if there is any. But due to continuous requests, it increases the bandwidth and server load which is not good.
2. Long Polling is an advanced version of polling where the client sends a request to the server and makes it open until it responds (It responds when new required data is generated) and then again client sends a request and so on. It is better than Polling but extra space and computation is required for the server to keep the server alive.
3. Socket is a protocol which provides a bi-directional communication channel. Socket uses ws and wss protocol where the initial request contains all required header information to process the request. Once the connection is established the next request requires less header information which reduces traffic over the network, sockets send continuous requests to the server but the bandwidth issue is resolved due to fewer data requests
Protocol buffers (protobufs)
As explained on https://developers.google.com/protocol-buffers/ Protocol buffers are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data — think XML, but smaller, faster, and simpler. It allows you to define the way you need your data to be structured once, after that you can use the specially created source code to efficiently write and read your structured data to and from the different data streams. It also allows you to use different languages too.
Here are the advantages of using PROTOBUF over JSON
1. Protobuf performs better than JSON, or any other.
3. It has more data types than JSON and is used more on RPC (Remote Procedure Calls).
4. It is 6 times faster than JSON.
5. The Formal Format is self-describing.
6. It has RPC Support
7. Message serialization on Potobuf can be automatically validated by the code.
For server communication, these are the best practices that you must follow. This is Part I of the blog in this series. Soon we share more details on this in the next blog. As a well-established mobile app development company in India, we ensure to follow these practices. We have the best mobile app developers to help our clients get the best results. We have also discussed the benefits of using Protbuf over JSON.
Understanding the growing demand, 9series has added a lot of new technologies this year. We will be providing many next-generation mobile app development services like AR/VR, IoT, Big Data and more. To know more about our services and expertise you can visit our Services page.