I want to load a file which is of type tar.gz into the memory as soon as the server starts so that I can perform operations with the requests that come in rather than loading the file every time a request a made. The way the file will load is through a function(load_archive)
def _get_predictor() -> Predictor:
check_for_gpu(-1)
archive = load_archive("{}/model.tar.gz".format(HOME),
cuda_device=-1)
return Predictor.from_archive(archive, "sentence-tagger")
The file mentioned in the code is very large(more than 2 GB) and I want an optimized way. I am creating an API which ultimately has to perform operations with this file. What I am thinking is loading this file once when the server starts and it remains in memory and serves all the requests fast enough without loading again and again and thus delaying the response. I have found some solution such as memcached or celery but I am not sure how can I use that and how to use that?
Please help me out.