+ All Categories
Home > Technology > tofu - COOKPAD's image system

tofu - COOKPAD's image system

Date post: 28-Jun-2015
Category:
Upload: issei-naruta
View: 7,798 times
Download: 4 times
Share this document with a friend
Description:
A slide which I talked about "tofu" at TOKYO Rails Meetup #5 http://www.tokyorails.org/events/39774252/
Popular Tags:
23
tofu COOKPAD’s image system Issei Naruta COOKPAD Inc. 2 Nov 2011
Transcript
Page 1: tofu - COOKPAD's image system

tofuCOOKPAD’s image system

Issei NarutaCOOKPAD Inc.

2 Nov 2011

Page 2: tofu - COOKPAD's image system

about me

Issei Naruta (なるた いっせい)

Engineer, COOKPAD Inc.

Infrastructure Team

image system / high performance web

twitter: @mirakui

Page 3: tofu - COOKPAD's image system

cookpad.com

900 million PV/month

Over 1 million recipes

Rails 3

AWS(Amazon Web Services)

Page 4: tofu - COOKPAD's image system

280x280

144x216

original image (1000x1000)

・・・

COOKPAD.has_many(:thumbnails)

Page 5: tofu - COOKPAD's image system

When/How do wegenerate thumbnails?

Page 6: tofu - COOKPAD's image system

app (rails)

Generate thumbnails

BEFORE TOFU (a year ago)

User uploads an image

storageoriginal thumbnails

Page 7: tofu - COOKPAD's image system

Problem

We should generate thumbnails ofall existing images as new sizewhen another size thumbnails are needed

(We have 7 million original images!)

Page 8: tofu - COOKPAD's image system

AFTER TOFU (now)

app (rails)

Store original imageUser uploads an image

storageoriginal original

tofu

Page 9: tofu - COOKPAD's image system

AFTER TOFU (now)

app (rails)

Store original image

storageoriginal

tofu

Generate thumbnailsOn demand

Page 10: tofu - COOKPAD's image system

akamai (cdn)

ELB

Apache(mod_tofu)

Apache(mod_tofu)

Apache(mod_tofu)…

S3

tofu architecture

Page 11: tofu - COOKPAD's image system

mod_tofu.so

C (Apache module)

Apache

ImageMagick

Page 12: tofu - COOKPAD's image system

thumbnail url

http://hostname/recipes/1/280/0e473ffbce0eb1e28a892fe4086b65b6.jpg

category

id

thumbnail size

SHA1(category+id+size+SECRET_WORD)

Page 15: tofu - COOKPAD's image system

‘100x100cq10’

‘100x100cq30’

‘100x100cq50’

‘100x100cq70’

‘100x100cq90’

jpeg quality (for mobile)

low

high

Page 16: tofu - COOKPAD's image system

On-demand resizing by url

Fast

Scalable

Page 17: tofu - COOKPAD's image system

On-demand resizing by url

Fast

Scalable

Page 18: tofu - COOKPAD's image system

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

Page 19: tofu - COOKPAD's image system

fetch images from S3

resize by ImageMagick

Page 20: tofu - COOKPAD's image system

On-demand resizing by url

Fast

Scalable

Page 21: tofu - COOKPAD's image system

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

Page 22: tofu - COOKPAD's image system

tofu effect

Our prototyping workflow became more fast and flexible

Save storage diskspace

Maintenance becomes easily

Page 23: tofu - COOKPAD's image system

Thank you for your listening


Recommended