I'm deploying a new version of my Flask application to Google App Engine (GAE) and am receiving a 500 server error before the home page even loads. The only difference in this new version is that I am loading an additional 26MB file into memory using the @app.before_first_request
decorator. In the previous, working version, I was loading in files in the same manner that amounted to 20MB at most.
Before loading in this file, my app was working well in production.
I have tried to update my app.yaml file to increase the size of the machine by adding in the following lines:
resources:
cpu: 2
memory_gb: 2.3
This is my app.yaml file:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /static
static_dir: static
- url: /.*
script: main.app
libraries:
- name: ssl
version: latest
- name: numpy
version: "1.6.1"
resources:
cpu: 2
memory_gb: 2.3
This is how I am loading the files into memory in main.py:
def get_gcloud_data(fname):
"""Retrieve file from GCS.
"""
base_link = 'http://fake_base_link/'
return pickle.loads(requests.get(base_link+fname).content)
@app.before_first_request
def startup():
global fake_var_name
fake_var_name = np.array(get_gcloud_data('pickled_file.p'))
I did not expect this additional file to cause such problems. Am I loading files into memory incorrectly (should I be doing this at all?)? How come I am getting this new 500 error?