Quantcast

Ruby on Rails, Io, Lisp, JavaScript, Dynamic Languages, Prototype-based programming and more...

Technoblog reader special: $10 off web hosting by FatCow!

Monday, June 25, 2007

Advanced Concepts in Ruby on Rails Hosting Part II

Last week, we were discussing the analogy of serving websites being similar to running a translation company. A request would come in as a document, be handed to an application server as a translator, and returned to the client. We left off with a scenario of three translation offices with 10 translators in each office. One of the simplest methods to distribute work among these translators is to hand out documents one at a time in a round-robin way. However, due to inherit traits of certain documents being longer than others and certain translators being faster than others, backups build up for some of the translators, leading to a random lag and customer complaints.

Rather than the brute force method of adding more offices and translators, can you think of a better way to distribute resources?

The bottleneck in the scenario sketched above is management. Our translation company still has only one manager, thus limiting his ability to distribute resources more effectively. If we hire office managers and let the manager hand documents to the office managers, this lets us think of more interesting distribution techniques. For example, instead of overwhelming our translators with a growing pile of documents, and thus a growing pile of responsibilities, the office manager can wait until each translator has finished their job before handing them a new document.

Let us think about the consequences of this change. First some assumptions. Assume John is faster at translating than Susie because he has less on his mind (in computer lingo this would mean that Susie is experiencing a memory leak, possibly due to a bad programming library). Further assume a pile of documents comes in with this order: a 10 page document, a 2 pager, a 20 pager, a 1 pager, a 3 pager. In our original setup we could easily find ourselves in the situation where Susie gets a pile with the 10 pager, the 20 pager, and finally the 3 pager; whereas John only got the 2 pager and 1 pager. You can see that Susie's 3 pager should have been easy and fast, but was stuck behind a few bigger documents and is in the hands of the slower translator.

With the new distribution algorithm, the worst case scenario would be that Susie would be chugging away at the 20 pager, but since John quickly made chump change of the other documents, he can turn over the the 3 pager before Susie even finishes the 20 pager. This is much more streamlined because the queue was processed as quickly as the resources freed themselves up as a group, not relying on the individual translator to handle the concurrency.

The typical Rails setup of a reverse proxy handing requests to mongrel is not the most efficient use of the resources, so I built a load balancer I call drproxy which sits between the reverse proxy and the Rails dispatchers and queues up requests, handing them out in a more efficient way as each resource is freed. Furthermore, I build drproxy in Erlang, a language built from the ground up to excel at concurrency. Ruby is a slug when it comes to handling concurrency and multi-threaded environments. Erlang is like a Porsche.

There are, however, even more ways to make the system more efficient in an algorithmic way. Think about it for a while and I will tell you what I did next week.

You should follow me on twitter here.

Technoblog reader special: click here to get $10 off web hosting by FatCow!

14 Comments:

Blogger Sam said...

Could you open source the erlang program you wrote?

12:00 PM, June 25, 2007

 
Blogger Lucas Carlson said...

Yes, I am just packaging it up, should be released soon.

12:01 PM, June 25, 2007

 
Anonymous Gregg Pollack said...

Isn't this what apache proxy load balancer is for?

If no, how is apache load balancer different then what you've created?

9:03 AM, July 04, 2007

 
Blogger Lucas Carlson said...

Please read the third installment. Apache's load balancer handles requests the same way a standard grocery store checkout works... a request goes into a line for one dispatcher, it doesn't matter if another dispatcher frees up before the assigned dispatcher is able to complete that request.

10:30 AM, July 04, 2007

 
Blogger Mark Imbriaco said...

I'm late to the party, but I was skimming your blog and noticed your writeup about drproxy. HAProxy supports the same idea of queueing up requests and passing them along to the next available downstream process. You're right that it makes a big difference not having to "get in line" behind slow requests.

4:45 PM, October 16, 2007

 
Blogger Zhenhong Bao said...

toms outlet
michael kors online
ralph lauren uk
coach factory outlet
tory burch outlet
replica watches
toms shoes
fitflops sale
coach outlet
michael kors factory outlet
oakley sunglasses wholesale
longchamp handbags
air max 90
michael kors handbags wholesale
louis vuitton sunglasses
michael kors outlet online
louis vuitton bags
oakley sunglasses
ray ban sunglasses
fitflops clearance
chaussure louboutin
swarovski crystal
michael kors outlet store
michael kors outlet sale
chrome hearts outlet
louboutin pas cher
coach outlet online
louis vuitton outlet
louis vuitton neverfull sale
ralph lauren outlet
rolex watches
swarovski outlet
nike huarache
oakley sunglasses
ralph lauren outlet
20160531zhenhong

6:21 PM, May 30, 2016

 
Blogger Zhenhong Bao said...

toms outlet
michael kors online
ralph lauren uk
coach factory outlet
tory burch outlet
replica watches
toms shoes
fitflops sale
coach outlet
michael kors factory outlet
oakley sunglasses wholesale
longchamp handbags
air max 90
michael kors handbags wholesale
louis vuitton sunglasses
michael kors outlet online
louis vuitton bags
oakley sunglasses
ray ban sunglasses
fitflops clearance
chaussure louboutin
swarovski crystal
michael kors outlet store
michael kors outlet sale
chrome hearts outlet
louboutin pas cher
coach outlet online
louis vuitton outlet
louis vuitton neverfull sale
ralph lauren outlet
rolex watches
swarovski outlet
nike huarache
oakley sunglasses
ralph lauren outlet
20160531zhenhong

6:24 PM, May 30, 2016

 
Blogger Tachra door said...


کرکره برقي
درب اتوماتيک شيشه اي
درب اتوماتيک
جک پارکينگ
جک پارکينگي
تعميرات
کرکره برقي
درب اتوماتيک شيشه اي
درب اتوماتيک
جک پارکينگ
تعميرات
قطعات خودرو
طراحي دکوراسيون
دکوراسيون داخلي
جک پارکينگ
جک پارکينگي
سئو سايت
طراحي سايت
درب اتوماتيک شيشه اي
درب شيشه اي

4:01 AM, July 28, 2016

 
Blogger Hua Cai said...

true religion jeans
snapbacks wholesale
michael kors outlet
nike air max 90
juicy couture outlet
ugg boots
air max 2015
fred perry polo
ralph lauren uk
nike roshe run
air max 90
fitflop sale
ugg outlet
nike roshe run shoes
nike roshe run
nike air max
oakley sunglasses
true religion jeans
longchamp handbags
tiffany jewellery
ugg outlet
cheap nfl jerseys
air max 90
nike outlet online
cheap soccer jerseys
nike air force 1
tory burch outlet online
rolex watches
tiffany jewelry
coach outlet online
chicago blackhawks jerseys
louis vuitton handbags outlet
lululemon outlet
reebok trainers
michael kors outlet
20160804caihuali

10:42 PM, August 03, 2016

 
Blogger Duc Le said...

Thanh xuân complex | hệ thống giáo dịch Thanh xuân tower | siêu thị tại The Link ciputra | bệnh viện ở Chung cư N01 Ngoại giao đoàn | trường học ở Eco lake view | Phòng khám tại Royal Park | hàng loạt dự án mới Vinhomes nguyen van huyen | nhiều căn hộ bất động sản Riverside Garden | Vinhomes hang bai | Tri ân khách hàng mua Quang minh tower | Cộng đồng cư dân sinh sống tại An phú shop villa | mục tiêu thực hiện Riverside Garden | bán nhà để mua N03 T3 T4 ngoại giao đoàn | bán đất để ở Lạc hồng Lotus Hạ Long | phố Sunshine Riverside | Xây dựng cơ sở Dragon Riverside | chủ đầu tư lớn chung cu Eco city long bien | Chủ đầu tư hàng đầu Nhà mẫu Chung cư 789 xuân đỉnh | Chủ đầu tư uy tín Gelexia Riverside | Kinh tế thị trường Smile trung yên building | thị trường mua bán Việt đức complex | thị trường đất Lavender Garden | thị trường đất đai Thạch bàn lakeside | chính thức mở bán South building | làm cho bằng được căn hộ HH01 Complex building | theo dõi tiến độ Hồng hà tower | công trình xây dựng lộc ninh singashine | công trình thi công Anland Nam cường | phương thức mua Grand world phú quốc | quy trình mua bán Chung cu king palace | dự án nội thành mặt bằng Chung cư Sao Ánh dương | Hanhud có nhiều tiền | PHối cảnh hiện nay Parkview City | Địa chỉ của Giá bán Chung cư 273 Tây sơn | chi tiết danh sách chung cư Chung cư T&T Riverview | Vị trí vàng Hải Đăng tower | Thông tin về thị trường nhà 201 Minh Khai City Plaza | Mức độ phục vụ Giá bán Chung cư 52 hàng bạc |

9:24 PM, August 12, 2016

 
Blogger Duc Le said...

Giá bán chung cư 120 định công | Bán nhà Giá bán chung ư 47 cát linh |

9:24 PM, August 12, 2016

 
Blogger Fangyaya said...

cleveland cavaliers jerseys
canada goose
rolex watches outlet
nike factory outlet
ralph lauren uk
basketball shoes
tory burch outlet
polo ralph kids
coach factory outlet
ralph lauren polo
michael kors outlet clearance
coach factory online
uggs on sale
christian louboutin pas cher
nike air max 90
ray ban sunglasses outlet
true religion sale
toms shoes
authentic louis vuitton handbags
coach factory outlet online
washington wizards jerseys
ugg boots
michael kors purses
jordan 11
ugg boots
uggs outlet
kate spade outlet
gucci handbags
cartier watches
chenyingying20160908

7:14 PM, September 07, 2016

 
Blogger chenlina said...

ugg australia
oakley sunglasses
coach outlet
tods shoes
oklahoma city thunder jerseys
fitflops uk
michael kors outlet
ed hardy clothing
designer handbags
coach outlet store online
chenlina20161018

7:51 PM, October 17, 2016

 
Blogger alfallah12345 said...

الجامعة المعترف بها في الامارات

11:22 PM, November 13, 2016

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

 

If you like this blog, you might also like top photography schools.