Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

265
Views
Google App Engine gunicorn worker timeout in Flask app when loading a large pickle?

I have a 350 MB Sklearn pickle file that I want to load on Flask app start up.

I use _pickle because it's mentioned in documentation that it has faster load time:

import _pickle as pickle

start = timeit.default_timer()
with open("pickle/pipeline.pkl", 'rb') as f: 
        # ~350MB file
        pipeline = pickle.load(f)
        stop = timeit.default_timer()
        print('Time: ', stop - start)

The pickle loads in 5-12 seconds locally but on Google App Engine F4 (1GB RAM) instance, the gunicorn worker times out.

Google App Engine log:

A 2019-10-20T20:07:55Z [2019-10-20 20:07:55 +0000] [14] [INFO] Booting worker with pid: 14

A 2019-10-20T20:11:02Z [2019-10-20 20:04:14 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:14)

I tried increasing the worker timeout by adding the -t flag in app.yaml file as follows and still doesn't work:

runtime: python
instance_class: F4
env: flex
entrypoint: gunicorn -t 120 -b :$PORT app:app

liveness_check:
  initial_delay_sec: 500

readiness_check:
  app_start_timeout_sec: 500

I even tried using eventlet and it didn't work:

gunicorn -t 120 -b :$PORT app:app --worker-class eventlet --workers 3 
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

The process of loading a 350 MB pickle data file is taking too long and App Engine thinks your instance has failed. Your container startup time is over three minutes.

You have a problem that cannot be easily solved. The maximum file size is 32 MB (64 MB for Go applications). You are downloading the file to memory, but your instance is taking too long to download it.

Solution: I would use a different service such as Cloud Run where you can embed your pickle data file in the container image so that downloads are not required.

over 4 years ago · Santiago Trujillo Report

0

Try with entrypoint: gunicorn -t 0 -b :$PORT app:app it worked for me.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!