How to configure the handling of large text files on the server using php?

Hello.

There is a script for podscheta words in the text, written in php.
Users will download the lyrics and get statistics of text.

Checked large texts are processed quite quickly, up to 2-5 seconds. The use of memory in the largest test text was 400 megabytes.

The question is how to configure the handling of files on the server. If 10 users simultaneously send texts for processing, memory is not enough.

Do I need 2 servers? One for site and one for word processing?
You need to write and configure a php daemon, which for example will keep track of downloaded files, obrabatyvat new and delete is processed?

What are the solutions?
March 19th 20 at 08:26
3 answers
March 19th 20 at 08:28
What are the solutions?

Yes, everything is in principle simple: don't put the contents of the entire file in RAM, it can be read in small chunks.
March 19th 20 at 08:30
$count = shell_exec("wc ".escapeshellarg($filename));
You think a line should be:
There is a script for podscheta words in the text

for this key -w like, but it's still not a solution because people probably need to consider not only the total number of words, but also to give statistics on frequency. - fatima_Strom commented on March 19th 20 at 08:33
Oh Yes, thank you. I'm so used lines to consider that in the machine wrote - Jaunita42 commented on March 19th 20 at 08:36
March 19th 20 at 08:32
like you direct road to lastinsert.
there's probably a snowball from grandpa Potter - linda.Larson commented on March 19th 20 at 08:35

Find more questions by tags PHP