Q
Q
qqqaa2021-07-17 17:59:45
In contact with
qqqaa, 2021-07-17 17:59:45

How is the VKontakte file system tripled?

I apologize in advance for possible shortcomings in the question, I'm still a beginner.
I recently started creating my site, and I became curious about 1 thing: if there are millions of user accounts on VKontakte, then it turns out that for each of them there is a separate folder / file on the server, to which you can go through the address bar, or it is implemented through a forced change in the state of the address bar itself through some scripts (say, using the history api). Just creating a bunch of separate files for each user would be at least inconvenient. Please explain how it all works so I don't make mistakes in the future.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
H
HemulGM, 2021-07-17
@HemulGM

The address bar does not mean the path through the "folders" on the server for a long time. This has not been used for a long time, but they use routing.
The address bar is divided into component parts, which can mean anything. It depends on the imagination of the developer. For example, https://site.ru/books/1
Here you see the main domain site.ru , then the section books , and 1 is the number of the book.
In this path, the site may not have either file 1 or the books folder at all. And the code of the books route will be launched, which will execute a query to the database and get the data of the book with id - 1.

S
Stanislav Makarov, 2021-07-17
@Nipheris

if there are millions of user accounts on VKontakte, then it turns out that for each of them there is a separate folder / file on the server

This assumption is fundamentally wrong. Most web frameworks now allow you to customize your URL templating mechanisms , and most of your site's pages are generated rather than stored on disk ready-made.
Read how the web backend of most sites is generally arranged now. In fact, these are all programs running on the server (and on large sites - a whole complex of programs located on many servers and interacting with each other), which can do a bunch of different actions (go to the database, process the input data received from the user, read files on disk, make requests to other services) and ultimately generate a response in the form of an HTML page, or in a machine-readable format, which is then processed on the client side, such as JSON or XML format.
If we simplify it very, very much, then the task of a programmer specializing in backend development is to write programs that accept HTTP requests, process them, and generate a response in the form of HTML / JSON / something else. Another thing is that "request processing" can be a very complex operation and consist of hundreds of smaller ones.

O
Oleg, 2021-07-17
@402d

https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html
For understanding the technique.
There are also terms "single entry point" and "routing".
Technical implementations may vary.
I don't know exactly how VK does it. Maybe some modification of nginx & fast-cgi
i.e. there are not thousands of files. the query string is parsed by the server software and the necessary actions are performed.

P
Puma Thailand, 2021-07-17
@opium

Explore the database dude

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question