GithubHelp home page GithubHelp logo

viterbi's Introduction

Tweet Tracker

This repository accompanies a presentation made for USC Course 31934, Spring 2016: Web Application Project.

Goal: Examine a traditional three tier web application compared to a stateful web service.

Contained within this repository are two API servers capable of tracking and persisting occurrences of hashtags, and responding with a global statistics counter.

  • Three-Tier: A traditional stateless web app delegating all stateful behavior to the database.
  • Stateful: A stateful web app leveraging in-process data locality to respond immediately to requests.

Both servers have two routes exposed:

  • GET /: Retrieves statistics on all tracked hashtags
  • POST /track?hashtag=<name>: Tracks a usage event of a particular hashtag.

Both servers are backed by a Postgres instance.

Instructions:

  • Clone repository, create the database, and ensure both servers can start.
  • Benchmark both servers for reading and writing.
  • (extra credit) - Generate 100k+ rows and repeat the benchmark.
  • Share and discuss results.

Database

Both apps use the same database. Once you have Postgres installed, create a database called tweets:

  1. createdb tweets
  2. psql -d tweets
  3. create table tweets (id serial primary key, hashtag text not null, created_at timestamp not null);

Starting your web server

  1. cd three_tier (or cd stateful)
  2. bundle install
  3. bundle exec ruby app.rb
  4. verify the app loads by going to http://localhost:4567/ on your browser

Benchmarking

Once you have a web server running, time to benchmark!

Install wrk: brew install wrk

# GET '/'
wrk -d10s --timeout 2000 http://localhost:4567/

# POST '/track?hashtag=<insert hashtag>'
wrk -d10s --timeout 2000 -s track.lua http://localhost:4567/

(Extra Credit) Generating Extra Rows

insert into tweets (hashtag, created_at) select 'hashtag_' || (s.i / 100)::text, now() as created_at from generate_series(1,100000) as s(i);

viterbi's People

Contributors

stavro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.