Guidelines for CPU and memory optimizations
See original GitHub issueHi,
First, let me start by thanking you for this beautiful and elegant solution. We are using Thumbor for last 6 months in production, serving on average 10,000,000 images/hour with zero issues. Now that we know the product is very stable, we would like to optimize the EC2 instances to further enhance Thumbor on processing more images/minute.
We are using a Thumbor stack deployed with AWS CloudFormation and an autoscaling group of c5.2xlarge CentOS7 EC2 instances, fully optimized to take advantage of the 10Gbit network infrastructure AWS offers. All images are cached with Akamai and whatever missed, is cached locally for an hour into a Redis cache.
Current infrastructure (image served with Thumbor🥇):
The thumbor-6.4.2 RPM is available into AXIVO repository. We use python-pillow-simd-4.3.0, as is 2.5 times faster compared to python-pillow-4.3.0 and proxy all calls through nginx-1.13.10. This allowed us to reduce the CPU usage by approximately 20%.
While CPU is currently floating around 75% values on each instance, I noticed the memory is partially used. This is the Thumbor configuration we use, on 8 processors and 16GB of RAM:
$ cat /etc/thumbor/thumbor.conf
ALLOW_OLD_URLS = False
ALLOW_UNSAFE_URL = False
AUTO_WEBP = True
DETECTORS = [
'thumbor.detectors.face_detector',
'thumbor.detectors.feature_detector',
'thumbor.detectors.glasses_detector',
'thumbor.detectors.profile_detector'
]
OPTIMIZERS = [
'thumbor.optimizers.jpegtran'
]
ENGINE_THREADPOOL_SIZE = 16
JPEGTRAN_PATH = '/bin/jpegtran'
HTTP_LOADER_MAX_CLIENTS = 16384
MAX_AGE = 2592000
MAX_AGE_TEMP_IMAGE = 60
STORAGE = 'tc_redis.storages.redis_storage'
STORAGE_EXPIRATION_SECONDS = 3600
REDIS_STORAGE_IGNORE_ERRORS = True
REDIS_STORAGE_SERVER_HOST = '0001.usw2.cache.amazonaws.com'
REDIS_STORAGE_SERVER_PORT = 6379
REDIS_STORAGE_SERVER_DB = 0
REDIS_STORAGE_SERVER_PASSWORD = None
RESULT_STORAGE = 'tc_redis.result_storages.redis_result_storage'
RESULT_STORAGE_EXPIRATION_SECONDS = 3600
REDIS_RESULT_STORAGE_IGNORE_ERRORS = True
REDIS_RESULT_STORAGE_SERVER_HOST = '0001.usw2.cache.amazonaws.com'
REDIS_RESULT_STORAGE_SERVER_PORT = 6379
REDIS_RESULT_STORAGE_SERVER_DB = 1
REDIS_RESULT_STORAGE_SERVER_PASSWORD = None
$ free -m
total used free shared buff/cache available
Mem: 15309 7604 5871 284 1834 7024
Swap: 0 0 0
$ systemctl --type=service --state=running list-units | grep thumbor
thumbor@8000.service loaded active running Thumbor (thumbor@8000)
thumbor@8001.service loaded active running Thumbor (thumbor@8001)
thumbor@8002.service loaded active running Thumbor (thumbor@8002)
thumbor@8003.service loaded active running Thumbor (thumbor@8003)
thumbor@8004.service loaded active running Thumbor (thumbor@8004)
thumbor@8005.service loaded active running Thumbor (thumbor@8005)
thumbor@8006.service loaded active running Thumbor (thumbor@8006)
thumbor@8007.service loaded active running Thumbor (thumbor@8007)
The ENGINE_THREADPOOL_SIZE
value is 2 x nproc
.
Are there any other settings I should take advantage of, to optimize the CPU usage and also increase the memory usage? @heynemann, @guilhermef, @cezarsa, your input is greatly appreciated on this matter.
Regards,
Floren Munteanu
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:27 (12 by maintainers)
Btw thank you VERY much for your kind words. We really appreciate it. It is good to hear that it has helped you as much as it has helped us and that baking extensibility into Thumbor, while not a primary concern for Globo.com has payed off many times by allowing us to collaborate with so many talented people! Thank you!
This issue was closed because it has been stale for 5 days with no activity.