Fwrite locks file for reading at the same time

I want to use data.table :: fwrite to quickly store and search for states in the form of text logs. They are updated through a mobile application that uses plumber API calls at endpoints R. Mobile applications can run many APIs per second, and it is possible that the same line will be changed by two APIs in the interval of ~ 0.5 seconds. I avoid reading and writing to the database due to a 1 ~ 2 second delay in calling the API (fwrite R can do the same job in 0.5 seconds for the first time, and then finish the API in less than 20 ms in subsequent calls)

My question is:

Will fwrite / fread work for a higher traffic scenario or do I have to look for ways to lock the file to avoid corruption? Are there any ways to lock a file for reading or writing?

+4
source share
1 answer

Will fwrite / fread work for a higher traffic scenario or do I need to look for ways to lock the file to avoid damage?

The answer is "it depends."

, singleton R, , , , . , , - , API ( data.table , , ).

, R , , .

API Plumber R. , , / , Plumber . SQLite, , ( 100%, SQLite ).

1-2 , . , / , - . API. , , .

+2

Source: https://habr.com/ru/post/1690714/


All Articles