All articles

Basics of the Client-Server Model

Sometimes new­com­ers to the tech indus­try think that every­thing is about writ­ing code. But really, there is so much that can be learned from under­stand­ing basic pat­terns that make up soft­ware devel­op­ment. This arti­cle is meant to explore one of those: the Client-Server Model.

The truth is that there are few pat­terns that are as wide­spread in our day-to-day lives than the Client-Server Model. Because of this, under­stand­ing more about it can lead to a bet­ter under­stand­ing of the tech­nol­ogy you use on a daily basis. Learning about what it is, what prin­ci­ples make it up, what are it’s fun­da­men­tals, all can help you in numer­ous sit­u­a­tions when work­ing with tech.

You don’t have to just be a devel­oper to ben­e­fit from under­stand­ing the Client-Server Model either. Managing releases, debug­ging, bench-mark­ing per­for­mance, and even break­ing down work prop­erly in tick­ets and user sto­ries; these are all things that can improve with even just a basic under­stand­ing of this build­ing block of mod­ern soft­ware devel­op­ment. Let’s get started!

What exactly is a Client?

Before we talk about this model, let’s first describe what a client is. Simply put, a client is a piece of soft­ware that runs as a “requester” of data. This could be a web­site you hit on your com­puter, an app on your phone, even desk­top apps that you run some­times. If you don’t write code for a liv­ing, there’s a pretty good chance that every piece of soft­ware you ever inter­act with (so long as it’s con­nected to a net­work) is a client in some capacity.

Security of a client

Clients have a few char­ac­ter­is­tics that might not be so obvi­ous at first glace. First, there’s the fact that the writ­ten soft­ware that runs as a client runs on a com­puter that is effec­tively out of the con­trol of the per­son who wrote the soft­ware. What I mean is that your phone, com­puter, smart-fridge, what­ever, is within the con­trol of the consumer.

This leads to the next char­ac­ter­is­tic, which is that clients are inher­ently less secure. For exam­ple, a web­site you visit’s actual “front-end” code (that is, all the code that dic­tates what you see) should not include any­thing sen­si­tive, or pro­vide any access to any­thing sen­si­tive. The same can be said for other types of clients as well, how­ever var­i­ous ecosys­tems are dif­fer­ing lev­els of secure.

Your local bank’s ATM is a client, but there are strict reg­u­la­tions on how its client-server rela­tion­ship func­tion, and there­fore its more secure. Apple and Android phones have stan­dards with which app devel­op­ers have to adhere to before sub­mit­ting apps to down­load on the open mar­ket. And even web browsers have very strict rules about what client code they run can and can­not do. Which inci­den­tally is why you should be care­ful about click­ing around on pop­ups or down­loads that you’re not sure of; these could be ways for nefar­i­ous actors to side­step some of these rules through the client.

The point of these exam­ples is not for you to be dis­suaded in the secu­rity of rep­utable soft­ware com­pa­nies. Instead, its to point out that these stan­dards and reg­u­la­tions are in place to com­bat the inher­ent fact of clients: they are by default not secure.

So what is a server then?

Now that we know a bit more about clients, lets talk about servers. Servers are soft­ware that han­dle requests that the clients ask about. They then issue “responses” for these requests. They are, in this pat­tern any­way, the source-of-truth when it comes to data that pow­ers applications.

Chances are, unless you write code in some capac­ity, you won’t ever inter­act with a server’s soft­ware directly. But that doesn’t mean its not use­ful to under­stand how they work!

Security of a Server

Whereas clients are inher­ently inse­cure, servers are the oppo­site. They run on envi­ron­ments that writ­ers of the soft­ware have much more (if not full) con­trol over. They’re designed in a way to act as the source of any­thing that might require sen­si­tive logic. Because of this inher­ent secu­rity, servers have access to things that clients shouldn’t. Things like data­base access, pass­codes to other servers, or user infor­ma­tion (though there’s secu­rity con­cerns around this even on servers).

How Clients and Servers talk to each other

Clients issue “requests”, and servers issue “responses” to those requests. We’ve already men­tioned these terms a few times, but lets go into a bit more detail here. A request usu­ally falls into two categories: get­ting data, or chang­ing data. While there are many tech­nolo­gies that are used to man­age requests and responses, eas­ily the most com­mon “pro­to­col” used nowa­days is called HTTP. In fact, you might even see those four let­ters at the start of web pages you visit.

Managing Getting Data

In HTTP terms, a request where a client asks for some­thing is called a GET request. A GET is made when you load up your favorite social media app, or visit a web­site and see the con­tent load up. Every sin­gle time you type in a URL, or hit a link on any device, a GET request is made first and fore­most. It does exactly what you’d think it does; a GET request is sent to the server from a client, with some infor­ma­tion about what the client is look­ing for (like a url, or other small bit of data).The server takes this request, looks at what the client wants to get, finds it (either in a data­base, or gen­er­ates it some­how) and sends a response back to the client.

How Data is Updated

These same prin­ci­ples are true if the client wants to update some data. We men­tioned how clients are inse­cure. However often times clients issue requests around updat­ing data. It’s up to the server to know how to han­dle those requests appro­pri­ately. In HTTP terms, this is called either a POST or a PUT request. They look fairly sim­i­lar to GET requests, except that the data added to the request is gen­er­ally used to update some data in a data­base by the server.

An exam­ple of this is some­thing like post­ing some­thing on social media, or updat­ing your email address on a web­site. These are issued as requests from a client and sent to a server, in order to cre­ate or update data.

Scale of this relationship

In its most sim­plis­tic form, a client-server model rela­tion­ship might only have one each of a client and server. However what is far more likely is for there to be many, many clients talk­ing to the same server. The logis­tics of net­work­ing behind this become com­pli­cated fairly quickly. However it is entirely pos­si­ble for thou­sands of clients to have iso­lated requests and responses going back and forth to the same server in any given sec­ond. This is how you can have many peo­ple using the same web­site, or lots of play­ers signed on to the same lobby.

Beyond this, there might even be mul­ti­ple copies of the same server work­ing for clients. This is often how com­pa­nies try and han­dle huge peaks of usage, where what­ever their nor­mal oper­at­ing capac­ity gets exceeded in a short period of time.

In recent mem­ory, tick­et­ing web­sites have had this very prob­lem where their traf­fic is rel­a­tively low most of the time, and then one night mil­lions of prospec­tive con­cert goers log on to try and get a ticket, all within sec­onds of each other.

Wrapping Up

As a con­clu­sion to this basic overview of the Client-Server Model, let’s wrap up by review­ing what we’ve cov­ered. A client runs on a consumer’s device, and requests data. It’s inher­ently inse­cure, as unless there’s some extra secu­rity guar­an­teed to be on the client device, the envi­ron­ment of the client is effec­tively out of the con­trol of the soft­ware developer.

Servers han­dle requests from clients, and issue responses for the data that has either been asked for, or asked to be updated. And of course, you can have lots and lots of clients talk­ing to the same server, and beyond that there might even be lots and lots of server han­dling the same task.

Hopefully this gives you some insight into this archi­tec­ture pat­tern; one that isn’t just fun­da­men­tal to soft­ware devel­op­ment, but to so many aspects of our mod­ern day lives.