29.11.2012 Views

2nd USENIX Conference on Web Application Development ...

2nd USENIX Conference on Web Application Development ...

2nd USENIX Conference on Web Application Development ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Abstract<br />

Integrating L<strong>on</strong>g Polling with an MVC <strong>Web</strong> Framework<br />

Eric Stratmann, John Ousterhout, and Sameer Madan<br />

Department of Computer Science<br />

Stanford University<br />

{estrat,ouster,sameer27}@cs.stanford.edu<br />

L<strong>on</strong>g polling is a technique that simulates server push<br />

using Ajax requests, allowing <strong>Web</strong> pages to be updated<br />

quickly in resp<strong>on</strong>se to server events. Unfortunately,<br />

existing l<strong>on</strong>g poll approaches are difficult to<br />

use, do not work well with server-side frameworks<br />

based <strong>on</strong> the Model-View-C<strong>on</strong>troller (MVC) pattern,<br />

and are not scalable. Vault is an architecture for l<strong>on</strong>g<br />

polling that integrates cleanly with MVC frameworks<br />

and scales for clustered envir<strong>on</strong>ments of hundreds of applicati<strong>on</strong><br />

servers. Vault lets developers focus <strong>on</strong> writing<br />

applicati<strong>on</strong>-specific code without worrying about the details<br />

of how l<strong>on</strong>g polling is implemented. We have implemented<br />

Vault in two different <strong>Web</strong> frameworks.<br />

1 Introducti<strong>on</strong><br />

In its earliest days the <strong>Web</strong> supported <strong>on</strong>ly static c<strong>on</strong>tent,<br />

but over the years it has evolved to support a variety<br />

of dynamic effects that allow <strong>Web</strong> pages to interact with<br />

users and update themselves incrementally <strong>on</strong> the fly. In<br />

the past most of these updates have been user-driven:<br />

they occurred in resp<strong>on</strong>se to user interacti<strong>on</strong>s such as<br />

mouse clicks and keystrokes. However, in recent years<br />

more and more applicati<strong>on</strong>s require server push, where<br />

<strong>Web</strong> pages update without any user involvement in resp<strong>on</strong>se<br />

to events occurring remotely <strong>on</strong> a <strong>Web</strong> server or<br />

even other browsers. Server push is particularly important<br />

for collaborati<strong>on</strong> applicati<strong>on</strong>s where users want to be<br />

notified immediately when other users perform acti<strong>on</strong>s<br />

such as typing messages or modifying a shared document.<br />

Server push is also useful for a variety of m<strong>on</strong>itoring<br />

applicati<strong>on</strong>s.<br />

The most comm<strong>on</strong> way to implement server push today<br />

is with a mechanism called l<strong>on</strong>g polling. Unfortunately,<br />

l<strong>on</strong>g polling is not easy to use. Existing implementati<strong>on</strong>s<br />

tend to be special-purpose and applicati<strong>on</strong>specific.<br />

They do not integrate well with Model-View-<br />

1<br />

C<strong>on</strong>troller (MVC) <strong>Web</strong> frameworks that are comm<strong>on</strong>ly<br />

used to build <strong>Web</strong> applicati<strong>on</strong>s, often requiring separate<br />

servers just for l<strong>on</strong>g polling. Finally, it is challenging to<br />

create a l<strong>on</strong>g polling system that scales to handle large<br />

<strong>Web</strong> applicati<strong>on</strong>s.<br />

In this paper we describe an architecture for l<strong>on</strong>g<br />

polling called Vault, al<strong>on</strong>g with its implementati<strong>on</strong>.<br />

Vault has three attractive properties:<br />

• It integrates with MVC frameworks in a natural and<br />

simple fashi<strong>on</strong> using a new c<strong>on</strong>struct called a feed,<br />

which is an extensi<strong>on</strong> of the model c<strong>on</strong>cept from<br />

MVC.<br />

• It generalizes to support a variety of l<strong>on</strong>g polling<br />

applicati<strong>on</strong>s (using different kinds of feeds), and to<br />

support multiple uses of l<strong>on</strong>g polling within a single<br />

<strong>Web</strong> page.<br />

• It includes a scalable notificati<strong>on</strong> system that allows<br />

Vault to be used even for very large applicati<strong>on</strong>s and<br />

that spares <strong>Web</strong> developers from having to worry<br />

about issues of distributed notificati<strong>on</strong>. There are<br />

two interesting architecture decisi<strong>on</strong>s in the design<br />

of the notificati<strong>on</strong> system. The first is that Vault separates<br />

notificati<strong>on</strong> from data storage, which makes<br />

it easy to create a scalable notifier and to incorporate<br />

a variety of data storage mechanisms into l<strong>on</strong>g<br />

polling. The sec<strong>on</strong>d is that extraneous notificati<strong>on</strong>s<br />

are allowed in Vault, which helps simplify the implementati<strong>on</strong><br />

of the system and crash recovery.<br />

Overall, Vault improves <strong>on</strong> existing work by making it<br />

easier to create <strong>Web</strong> applicati<strong>on</strong>s that use l<strong>on</strong>g polling.<br />

We have implemented Vault in two <strong>Web</strong> frameworks.<br />

We first built Vault in Fiz [10], a research framework,<br />

and then ported it to Django [3] to dem<strong>on</strong>strate the general<br />

applicability of Vault in MVC frameworks. This paper<br />

uses the Django implementati<strong>on</strong> for examples, but<br />

the c<strong>on</strong>cepts and techniques could be used in most other<br />

MVC frameworks.<br />

<str<strong>on</strong>g>USENIX</str<strong>on</strong>g> Associati<strong>on</strong> <strong>Web</strong>Apps ’11: <str<strong>on</strong>g>2nd</str<strong>on</strong>g> <str<strong>on</strong>g>USENIX</str<strong>on</strong>g> <str<strong>on</strong>g>C<strong>on</strong>ference</str<strong>on</strong>g> <strong>on</strong> <strong>Web</strong> Applicati<strong>on</strong> <strong>Development</strong> 113

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!