Answer the question
In order to leave comments, you need to log in
How does the number of files affect server performance?
I searched but did not find a clear answer, how the number of directories and files will affect the operation of the server and how noticeable the difference will be if there is, with the number of directories about 300 thousand, each with several (up to 20) files. I already understood that you can’t put them all in one directory, but what if they are divided into directories? How relevant is this question, to say think about storing files on another server.
and the second question is related. when accessing the site, they usually process the cnc-url through php and look in the database, I always had a question why not create real directories and put a php file with id in them, etc., so that later you can quickly find the data in the database.
Answer the question
In order to leave comments, you need to log in
the number of files in itself (even in the same directory) does not affect performance in any way.
but, for example, when receiving a listing of such a directory or its backup, I will experience brakes.
1. The speed of working with a bunch of files is theoretically the same as with the database. But the caching of the file system and the database goes differently. And if, when accessing a table, it is cached all at once, then it is not so easy to cache 300,000 files / directories.
2.
When accessing the site, they usually process the cnc-url through php and look in the database, I always had a question why not create real directories and put a php file with id, etc. in them, so that later you can quickly find the data in the database."
In short, it does. No one will tell you how noticeable it will be, there are many conditions.
The database also consists of files.
Julia , if the CNC field in the database is indexed, then the search for it will be fast enough.
If we are talking about small business card sites, then it doesn’t matter what to do with storing data, in files or in a database. If you make large sites (blogs, registration, comments, product catalog) - then already at the database design stage - this question disappears by itself. Read about relational databases. It is impossible to organize this on files, since there are relationships between the fields of the database, and they cannot be done between files. Complex SQL queries cannot be applied to files.
In addition, modern databases are powerful software focused on reliability and speed.
I recommend watching a series of videos with HightLoad ++. Many reports about services withstanding high loads
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question