question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Guidelines for CPU and memory optimizations

See original GitHub issue

Hi,

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🥇): Thumbor Infrastructure 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:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:27 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
heynemanncommented, Mar 22, 2018

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!

0reactions
github-actions[bot]commented, Jan 28, 2022

This issue was closed because it has been stale for 5 days with no activity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 Optimizing Applications and CPU Performance
3.3 Optimizing CPU Resources · Use the Class Scheduler to allocate CPU resources · Prioritize jobs so that important applications are run first...
Read more >
Techniques for Optimizing CPU Performance
Techniques for Optimizing CPU Performance · Reducing CPU Time By Using More Memory or Reducing I/O · Storing a Compiled Program for Computation- ......
Read more >
How to Optimize Your RAM For Maximum Performance
Track Used Memory and Run Clean-Up Processes · Disable Unwanted Startup Programs · Try a Different Browser · Software Update · Use the...
Read more >
Optimize CPU options - Amazon Elastic Compute Cloud
Optimize CPU options · Number of CPU cores: You can customize the number of CPU cores for the instance. · Threads per core:...
Read more >
Chapter 31. Configuring an operating system to optimize ...
31.1. Tools for monitoring and diagnosing processor issues · The instructions per cycle (IPC). · The count of last level cache MISSES. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found