文件创建限制

Dear respective developer across the globe,

  • I'm only seeking knowledge and understanding. Please provide as much

information as you can to not only help me out, but also others around the

world.

I will divide my questions so it's easier to understand what i'm asking for

and allow you to answer the questions individually for better

understanding.

My questions is:

a)

  • I'm runing a home server using mamp pro on a windows 8 32gb ram, 4k ssd, i7 cpu.My server is dns is set with cloudflare.com. When people from the public world view my site there is a php script that create a text-file with their username. Like: {username}.txt. For every username. The same file get re-created everytime the user login to keep the data fresh about him. That was some information about what i'm doing. What i want to understand is. Is there any limits? let say 500000 people at same time try to reach my site and every user will make my site create a new fresh txt file for him. Will it work? is there any problem.. please share with me.

b)

Can a textfile get views by let say 1000000 as same time? i'm talking about viewed not created here.

The number of files is not limited at all by the operating system or by php.

But is is limited by the file system you safe the files in. The exact numbers depend on the type of file system and its configuration. Typical limits are 32000 inodes in a single directory. But as mentioned that can be configured.

What is typically done in such cases is that you spread all those files over directories, where the directories are named by a substring of the file name itself. So for example the file somegoodguy.txt is saved under /som/ego/odg/somegoodguy.txt. Provided you have a more or less equal usage of characters that should prevent that you hit any limits, since the files are equally spread over many, many folders.


However:

It is questionable if that is a good approach at all. File based storage is not exactly efficient. You get a much better performance if you use a database instead. One entry (row) per user in a database table. Accessing that information is really efficient and fast. And you don't have to worry about any limits.