Date post: | 28-Jun-2015 |
Category: |
Technology |
Upload: | issei-naruta |
View: | 7,798 times |
Download: | 4 times |
tofuCOOKPAD’s image system
Issei NarutaCOOKPAD Inc.
2 Nov 2011
about me
Issei Naruta (なるた いっせい)
Engineer, COOKPAD Inc.
Infrastructure Team
image system / high performance web
twitter: @mirakui
cookpad.com
900 million PV/month
Over 1 million recipes
Rails 3
AWS(Amazon Web Services)
280x280
144x216
original image (1000x1000)
・・・
COOKPAD.has_many(:thumbnails)
When/How do wegenerate thumbnails?
app (rails)
Generate thumbnails
BEFORE TOFU (a year ago)
User uploads an image
storageoriginal thumbnails
Problem
We should generate thumbnails ofall existing images as new sizewhen another size thumbnails are needed
(We have 7 million original images!)
AFTER TOFU (now)
app (rails)
Store original imageUser uploads an image
storageoriginal original
tofu
AFTER TOFU (now)
app (rails)
Store original image
storageoriginal
tofu
Generate thumbnailsOn demand
akamai (cdn)
ELB
Apache(mod_tofu)
Apache(mod_tofu)
Apache(mod_tofu)…
S3
tofu architecture
mod_tofu.so
C (Apache module)
Apache
ImageMagick
thumbnail url
http://hostname/recipes/1/280/0e473ffbce0eb1e28a892fe4086b65b6.jpg
category
id
thumbnail size
SHA1(category+id+size+SECRET_WORD)
resizing
/recipes/1/280/0e473ffbce0eb1e28a892fe4086b65b6.jpg
width=280
height=free
cropping
/recipes/1/100x100c/819d7abe2a8b9261aa3c43e948abe7b3.jpg
100 x 100& center cropping
‘100x100cq10’
‘100x100cq30’
‘100x100cq50’
‘100x100cq70’
‘100x100cq90’
jpeg quality (for mobile)
low
high
On-demand resizing by url
Fast
Scalable
On-demand resizing by url
Fast
Scalable
akamai (cdn)
ELB
Apache(mod_tofu)
Apache(mod_tofu)
Apache(mod_tofu)…
S3
EC2 c1.xlarge(8cores)
8 instances100 req/secper instance
800 req/sec
7000 req/sec
Peak traffic
fetch images from S3
resize by ImageMagick
On-demand resizing by url
Fast
Scalable
akamai (cdn)
ELB
Apache(mod_tofu)
Apache(mod_tofu)
Apache(mod_tofu)…
S3
tofu scalability = AWS scalability
autoscalingby itself
Oh yeahIt has a huge
capacity!
more instances, more capacity
tofu effect
Our prototyping workflow became more fast and flexible
Save storage diskspace
Maintenance becomes easily
Thank you for your listening