Competitious on Rails - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Competitious on Rails

Description:

Competitious on Rails. Kris Rasmussen, Andrew Holt. Competitious on Rails. Who we are ... Sharepoint - worked on blogs, scripting security, wikis, UI, and ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 32
Provided by: kri666
Category:

less

Transcript and Presenter's Notes

Title: Competitious on Rails


1
Competitious on Rails
  • Kris Rasmussen, Andrew Holt

2
Competitious on Rails
  • Who we are
  • What is Competitious
  • Why Ruby on Rails?
  • Pros/Cons
  • Competitious code

3
Andrews Background
  • B.S. in Computer Science from Stanford
  • Engineer and project manager at Yahoo!
  • Co-founded Revunity
  • Interim creations
  • Co-founded RivalSoft (Competitious)

4
Kris Background
  • Web and mobile 3D graphics engines
  • CS and Math from UCLA
  • Internet design and engineering consultant
  • Software Engineer at Microsoft
  • Sharepoint -gt worked on blogs, scripting
    security, wikis, UI, and extensibility of the
    platform
  • Started PersonalTrainerPages.com, built on top of
    a scalable, drag and drop AJAX based vertical
    content management platform
  • Started Competitious

5
Competitious
  • Online service that enables companies to better
    discover, organize, and analyze data on
    competition
  • Initial beta release in October, 2006
  • Plan to change the way companies consume and act
    on competitive information

6
(No Transcript)
7
(No Transcript)
8
(No Transcript)
9
(No Transcript)
10
(No Transcript)
11
Considering Web Technologies
  • Development speed
  • Libraries Frameworks
  • Scalability
  • Maintainability
  • MVC
  • Components, Templating
  • Code readability
  • Code size

12
Why we chose Ruby on Rails
  • Less configuration and plumbing code required
  • No template languages
  • Easier to test, and iteratively develop
  • Less emphasis on broad packaged components
  • Elegant and familiar syntax
  • Non-bloated JS libraries and slick AJAX

13
It worked!
  • We built the first version of Competitious in 3
    weeks!
  • Partials and Helpers enabled common functionality
    to be shared much more easily than component
    based frameworks
  • We have been able to constantly evolve the
    service and the database and respond quickly to
    customer feedback

14
But there are problems...
  • Refactoring code is difficult
  • Single threaded/memory heavy processes
  • Needs some work to get production mode really
    ready for production
  • Does not support some complex queries
  • Fetches all the data, all the time
  • Easy to over-query the database

15
Production Checklist
  • Automatic deployment SVN Capistrano Mongrel
  • Filter sensitive data out of logs
  • filter_parameter_logging password
  • Store sessions in memory or in the database
  • Clear them when they expire
  • Keep database round trips to a minimum, cache
    when necessary
  • Ensure your Web Server is serving static files!
  • Security reviews cross site scripting, sql
    injection, and permissions on objects when
    referencing by id
  • Dont rely on with_scope!

16
Glimpse into Competitious
  • Not fully RESTful yet
  • Lots of Many to many relationships, dont limit
    yourself unless performance really is an issue
  • Acts as everything
  • Acts_as_noteable
  • Acts_as_loggable (more on this later)
  • Acts_as_securable
  • Acts_as_taggable
  • Acts_as_mediable
  • 19 controllers, 18 models

17
Biggest Performance Issue
  • Waiting on other services
  • When other services go down or respond slowly
    your service shouldnt
  • Why is this a problem
  • You cant run many rails processes at once
    (memory)
  • You cant count on 3rd parties

18
Step 1 Caching
  • Reduce number of times you have to wait.
  • Simple time based ObjectCache
  • data ObjectCache.cache(key,CACHE_TIME) do
    request_3rd_party_data(key)end
  • Reduces average wait time but users will still
    encounter worst wait time for ever.
  • Not all TOS allow you to cache

19
Step 2 Timeouts
  • Ensure your rails processes are available!
  • status Timeouttimeout(3) do
    NetHTTP.get(url)
  • end
  • When all else fails fall back on cached data
  • Problem user still has to wait for longer than
    they should when other data might be ready

20
Step 3 Asynchronous Polling
  • Start up new processes/threads to communicate
    with the third party service at the beginning of
    the request
  • Use lighter weight processes for this
    (backgroundDRb)
  • If by the end of the request the data is
    available, then display it
  • If not then use AJAX to poll the server after
    the page is rendered

21
Making AJAX more responsive
  • Dont hit the server unless absolutely necessary
  • Common when doing in place editing
  • You dont have to duplicate view logic in
    Javascript using ugly inner HTML or the DOM.

22
Javascript Templates
  • Write a simple js template engine
  • Example Template
  • lt define_js_template("new_feature_tmpl") do
    gt lttr id"new-feature-row-(id)"
    class"new-feature-row"gt lt end gt
  • render_js_template(new_feature_tmpl",'id'id,'ty
    pe'type,'type_name'type_name)

23
How does it work?
  • Rails Generated html is embedded inside hidden
    textareas
  • Client Javascript loads template and replaces
    variables with current parameters
  • Advantages All view code in one place, less
    server round trips, dont need to write much
    Javascript
  • See our Comparison Matrix for an example

24
Activity Logging
  • Problems associated with activity logging
  • Records may be created/updated/destroy etc in
    multiple places
  • Each record has different data that should be
    displayed in the log
  • After records are updated/deleted log entries and
    references need to be updated

25
(No Transcript)
26
acts_as_loggable !
  • Model
  • acts_as_loggable name
  • Controller
  • Media.with_logging(user gt_at_current_user) .
  • Use in an around_filter
  • Views
  • Create partials for rendering log for each
    loggable type

27
Models
  • class LogEntry lt ActiveRecordBase
  • belongs_to log_object
  • belongs_to user
  • end
  • class LogObject lt ActiveRecordBase
  • belongs_to loggable, polymorphic gt true
  • has_many log_entries, dependentgtdestroy
  • end

28
(No Transcript)
29
Advanced Usage
  • acts_as_loggable name,mediable_type,mediable_i
    d,mediablegtname
  • Media.with_logging(actiongt'published') do
  • _at_media.update_attribute('published',true)
  • End
  • Media.with_logging(datagtextradata)
  • Acts_as_loggable record,extradata return
    hash_of_data

30
Plugin will be posted on our blog
  • http//blog.competitio.us

31
Contact Us
  • Kris
  • kris_at_competitio.us
  • Andrew
  • andrew_at_competitio.us
Write a Comment
User Comments (0)
About PowerShow.com