Movatterモバイル変換


[0]ホーム

URL:


Barry Jones, profile picture
Uploaded byBarry Jones
PPTX, PDF3,239 views

Exploring Ruby on Rails and PostgreSQL

The document explores the advantages of using Ruby on Rails with PostgreSQL from the perspective of an application developer, Barry Jones. It discusses key considerations in choosing programming languages and frameworks, the benefits and drawbacks of Ruby, as well as practical applications involving Rails, database management, and testing. Additionally, the document highlights the capabilities and features of PostgreSQL, including full-text search and various data types.

Embed presentation

Downloaded 26 times
Exploring Ruby on Railsand PostgreSQL
Who am I?• I’m Barry Jones• Application Developer since ’98– Java, PHP, Groovy, Ruby, Perl, Python– MySQL, PostgreSQL, SQL Server, Oracle, MongoDB• Efficiency and infrastructure nut• Believer in “right tool for the job”– There is no silver bullet, programming is abouttradeoffs
The Silver BulletRuby on Rails and PostgreSQLj/k But it’s close
What do we look for in a language?• Balance– Can it do what I need it to do?• Web: Ruby/Python/PHP/Perl/Java/C#/C/C++– Efficient to develop with it?• Ruby/Python/PHP– Libraries/tools/ecosystem to avoid reinventing the wheel?• Ruby/Python/PHP/Java/Perl– Is it fast?• Ruby/Python/Java/C#/C/C++– Is it stable?• Ruby/Python/PHP/Perl/Java/C#/C/C++– Do other developers use it?• At my company? In the area? Globally?– Cost effective?• Ruby/Python/PHP/Perl/C/C++– Can it handle my architectural approach well?• Ruby/Python/Java/C# handle just about everything• CGI languages (PHP/Perl/C/C++) are very bad fits for frameworks, long polling, evented programming– Will it scale?• Yes. This is a subjective question because web servers scale horizontally naturally– Will my boss let me use it?• .NET shop? C#• Java shop? Java (Groovy, Clojure, Scala), jRuby, jython• *nix shop? Ruby, Python, Perl, PHP, C, C++• Probable Winners: Ruby and Python
What stands out about Ruby?• Malleability– Everything is an object– Objects can be monkeypatched• Great for writingDomain SpecificLanguages– Puppet– Chef– Capistrano– Rails“this is a string object”.lengthclass Stringdef palindrome?self == self.reverseendend“radar”.palindrome?
How is monkey patching good?• Rails adds web specific capabilities to Ruby– “ “.blank? == true• Makes using 3rd party libraries much easier– Aspect Oriented Development• Not dependent on built in hooks– Queued processingrecord = Record.find(id)record.delay.some_intense_logic• DelayedJob• Resque• Sidekiq• Stalker– Cross integrationsEmail.deliver• MailHopper – Automatically deliver all email in the background• Gems that specifically enhance other gems
How is monkey patching…bad?• If any behavior is modified by a monkey patchthere is a chance something will break• On a positive note, if you’re writing tests andfollowing TDD or BDD the tests should catchany problems• On another positive note, the ruby communityis very big on testing
Why was Ruby created?• Created by Yukirio Matsumoto• "I wanted a scripting language that was morepowerful than Perl, and more object-orientedthan Python.”• "I hope to see Ruby help every programmer inthe world to be productive, and to enjoyprogramming, and to be happy. That is theprimary purpose of Ruby language.”– Google Tech Talk in 2008
Ruby Version Manager• cd into directoryautoselects correctversion of ruby andgemset• Makes running multipleprojects with multipleversions of ruby andgem dependencies onone machine deadsimple.rvmrc filervm rubytype-version-patch@gemsetExamples:rvm ruby-1.9.3-p327@myprojectrvm jruby-1.7.4@myjrubyprojectrvm ree-1.8.7@oldproject
Bundler and Gemfile$ bundle installUsing rake (10.0.4)Using i18n (0.6.1)Using multi_json (1.7.2)Using activesupport (3.2.13)Using builder (3.0.4)Using activemodel (3.2.13)Using erubis (2.7.0)Using journey (1.0.4)Using rack (1.4.5)Using rack-cache (1.2)Using rack-test (0.6.2)…Your bundle is complete! Use `bundle show[gemname]` to see where a bundled gem isinstalled.source 'https://rubygems.org'source 'http://gems.github.com'# Application infrastructuregem 'rails', '3.2.13'gem 'devise'gem 'simple_form'gem 'slim'gem 'activerecord-jdbc-adapter’gem 'activerecord-jdbcpostgresql-adapter'gem 'jdbc-postgres'gem 'jruby-openssl'gem 'jquery-rails'gem 'torquebox', '2.3.0'gem 'torquebox-server', '~> 2.3.0'
ForemanNot Ruby specific but written in rubyUsed with HerokuDrop in a Procfile$ foreman start CTRL + C to stop everythingProcfileweb: bundle exec thin start -p $PORTworker: bundle exec rake resque:work QUEUE=*clock: bundle exec rake resque:scheduler
jRuby: Why?Ruby isn’t perfect• Some gems can create memory leaks– esp. if they were written with native C• Does not have kernel level threading– Global Interpreter Lock• Everything is an object means unnecessaryprocessing happens when doing things likeadding numbers leading to a performance hit
jRuby: So how does it fix things?I hate writing Java…but the JVM is a work of art• Java infrastructure is virtually bulletproof– Most mature way to deploy a web application– Enterprisey • JVM’s garbage collector is best of breed and eliminates the potentialmemory leak issues• JVM’s Just-In-Time compiler continually optimizes code the longer it runsmaking it faster• JVM gives Ruby kernel level threading• jRuby inspects your Ruby code to see if you’re doing anything it wouldprefer you didn’t…and turns it off if you’re not– Eg. If you aren’t overloading the + operator on int’s, it will convert them tobasic types instead of running as objects• Include and use very mature Java libraries directly in your Ruby code– Significantly expands your toolbelt– Allows easy integration into existing Java environments
The Sidekiq TestSidekiq is a multithreaded backgroundworker that provides tremendousconcurrency benefitsCreating 1,000,000 objects in 50concurrent threadsRubyjRuby
The App Server TestCPU Usage
The App Server TestFree Memory
The App Server TestLatency
The App Server TestThroughput
Update and Clarification• As of this posting to Slideshare, Torquebox has a mature version 3and a prototype version 4 that operates in a “web server only”mode. Ruby is at version 2.1.0 with dramatic improvements tomemory performance with forking which allows higherconcurrency.• At this time, jruby still wins but it’s much closer. Based on chatterfrom the #jruby IRC channels, a major new release of both jRubyand Torquebox are expected to dramatically improve theirperformance thanks to recent Java updates. The expected timelinewas late 2014 last I heard.• Independent benchmarks can be found here:http://www.techempower.com/benchmarks/#section=data-r9&hw=peak&test=json
RUBY ON RAILSLet’s take a break before covering…
What do we look for in a framework?• Please don’t suck– Rails does not suck• Does it follow Model-View-Controller?– Yes– Since Rails 1 it’s been the standard bearer for how to do MVC on the web, copied in almost every language• Does it help me avoid repeating myself (DRY)?– Yes• Is it self documenting?– Yes, it has a set of rules that generally make most documentation unnecessary• Is it flexible enough to bend to my application needs?– Yes• Do other people use it?– Good gosh yes• Will it work with my database?– Yes• Is it still going to be around in X years?– Ruby has Rails– Python has Django– Groovy has Grails– C# has MVC– PHP has fragmented framework Hell (aka – who knows?)– Java has a few major players (Struts 2, Play, etc)
Rails: The BasicsBrowserRackRouterController +ModelsView
Rails: RackWatch this excellent walkthrough of RackMiddleware:http://railscasts.com/episodes/151-rack-middlewareSummary:It’s a layer of ruby code that passes requests into your app andsends responses back out. You can add layers to do pre/postprocessing on all requests prior to beginning ANY of yourapplication code.
Rails: Models / ActiveRecordclass Post < ActiveRecord::Basebelongs_to :categoryhas_many :tags, through: :posts_tagsvalidates :title, presence: truebefore_save :create_slug, only: :createscope :newest_first, order(‘created_at DESC’)scope :active, where(‘active = ?’,true)scope :newest_active, newest_first.activescope :search, lambda do |text|where(‘title LIKE ?’,”%#{text}%”)enddef create_slugself.slug = title.downcase.squish.sub(‘ ‘,’-’)endendpost = Post.new(title: ‘Some title’)post.save!ORpost = Post.create(title: ‘Some title’)post.slug # some-titlepost.id # 1post.created_at # Created datetimepost.updated_at # Updated datetimepost.title = ‘New title’post.save!# Relationspost.tags.firstpost.tags.countpost.category.namepost = Post.include(:tags) # Eager loadpost =Post.search(‘some’).newest_active.first
Rails: Migrationsclass CreateInitialTables < ActiveRecord::Migrationdef upcreate_table :posts do |t|t.string :titlet.text :bodyt.string :slugt.integer :category_idt.timestampsend# … create more tables…add_index :tags, [:name,:something], unique: trueexecute “UPDATE posts SET field = ‘value’ WHERE stuff = ‘happens’”enddef downdrop_table :postsenddef changeadd_column :posts, :user_id, :integerendend$ rake db:migrate
Rails: ControllersClass PostsController < ApplicationControllerbefore_filter :authenticate, only: :destroydef index # GET /postsenddef new # GET /posts/newenddef create # POST /postsenddef show # GET /posts/:idenddef edit # GET /posts/:id/editenddef update # PUT /posts/:idenddef destroy # DELETE /posts/:idendend# Routesresources :postsOR limit itresources :posts, only: [:create,:new]
Rails: Views/app/views/layouts/application.html.erb/posts/new.html.slim/new.json.rabl/index.xml.erb/_widget.html.erb# slim example.posth2=post.title.body.grid-8=post.body# erb example<div class=“post”><h2><%=post.title%></h2><div class=“body grid-8”><%=post.body%></div></div>
Rails: Testing with rspecDescribe Post dodescribe ‘a basic test’ dosubject { FactoryGirl.build(:post,title: ‘Some title’) }it ‘should be valid’ doshould_not be_nilsubject.valid?.should be_trueendenddescribe ‘something with a complicated dependency’ dobefore doPost.stub(:function_to_override){ true }endenddescribe ‘a test with API hits’ douse_vcr_cassette ‘all_a_twitter’, record: :new_episodesendend
POSTGRESQLLet’s take a break before we talk about…
How do you pronounce it?Answer Response Percentagepost-gres-q-l 2379 45%post-gres 1611 30%pahst-grey 24 0%pg-sequel 50 0%post-gree 350 6%postgres-sequel 574 10%p-g 49 0%database 230 4%Total 5267
What IS PostgreSQL?• Fully ACID compliant• Feature rich and extensible• Fast, scalable and leverages multicoreprocessors very well• Enterprise class with quality corporatesupport options• Free as in beer• It’s kind’ve nifty
Laundry List of Features• Multi-version Concurrency Control (MVCC)• Point in Time Recovery• Tablespaces• Asynchronous replication• Nested Transactions• Online/hot backups• Genetic query optimizer multiple index types• Write ahead logging (WAL)• Internationalization: character sets, locale-aware sorting, case sensitivity,formatting• Full subquery support• Multiple index scans per query• ANSI-SQL:2008 standard conformant• Table inheritance• LISTEN / NOTIFY event system• Ability to make a Power Point slide run out of room
What are we covering today?• Full text-search• Built in data types• User defined data types• Automatic data compression• A look at some other cool features andextensions, depending how we’re doing ontime
Full-text Search• What about…?– Solr– Elastic Search– Sphinx– Lucene– MySQL• All have their purpose– Distributed search of multiple document types• Sphinx– Client search performance is all that matters• Solr– Search constantly incoming data withstreaming index updates• Elastic Search excels– You really like Java• Lucene– You want terrible search results that don’t evenmake sense to you much less your users• MySQL full text search = the worst thing in the world
Full-text Search• Complications of stand alone search engines– Data synchronization• Managing deltas, index updates• Filtering/deleting/hiding expired data• Search server outages, redundancy– Learning curve– Character sets match up with my database?– Additional hardware / servers just for search– Can feel like a black box when you get a supportquestion asking “why is/isn’t this showing up?”
Full-text Search• But what if your needs are more like:– Search within my database– Avoid syncing data with outside systems– Avoid maintaining outside systems– Less black box, more control
Full-text Search• tsvector– The text to be searched• tsquery– The search query• to_tsvector(‘the church is AWESOME’) @@ to_tsquery(SEARCH)• @@ to_tsquery(‘church’) == true• @@ to_tsquery(‘churches’) == true• @@ to_tsquery(‘awesome’) == true• @@ to_tsquery(‘the’) == false• @@ to_tsquery(‘churches & awesome’) == true• @@ to_tsquery(‘church & okay’) == false• to_tsvector(‘the church is awesome’)– 'awesom':4 'church':2• to_tsvector(‘simple’,’the church is awesome’)– 'are':3 'awesome':4 'church':2 'the':1
Full-text Search• ALTER TABLE mytable ADD COLUMN search_vector tsvector• UPDATE mytableSET search_vector = to_tsvector(‘english’,coalesce(title,’’) || ‘ ‘ ||coalesce(body,’’) || ‘ ‘ || coalesce(tags,’’))• CREATE INDEX search_text ON mytable USING gin(search_vector)• SELECT some, columns, we, needFROM mytableWHERE search_vector @@ to_tsquery(‘english’,‘Jesus & awesome’)ORDER BY ts_rank(search_vector,to_tsquery(‘english’,‘Jesus & awesome’))DESC• CREATE TRIGGER search_update BEFORE INSERT OR UPDATEON mytable FOR EACH ROW EXECUTE PROCEDUREtsvector_update_trigger(search_vector, ’english’, title, body, tags)
Full-text Search• CREATE FUNCTION search_trigger RETURNS trigger AS $$beginnew.search_vector :=setweight(to_tsvector(‘english’,coalesce(new.title,’’)),’A’) ||setweight(to_tsvector(‘english’,coalesce(new.body,’’)),’D’) ||setweight(to_tsvector(‘english’,coalesce(new.tags,’’)),’B’);return new;end$$ LANGUAGE plpgsql;• CREATE TRIGGER search_vector_updateBEFORE INSERT OR UPDATE OF title, body, tags ON mytableFOR EACH ROW EXECUTE PROCEDURE search_trigger();
Full-text Search• A variety of dictionaries– Various Languages– Thesaurus– Snowball, Stem, Ispell, Synonym– Write your own• ts_headline– Snippet extraction and highlighting
Datatypes: ranges• int4range, int8range, numrange, tsrange, tstzrange, daterange• SELECT int4range(10,20) @> 3 == false• SELECT numrange(11.1,22.2) && numrange(20.0,30.0) == true• SELECT int4range(10,20) * int4range(15,25) == 15-20• CREATE INDEX res_index ON schedule USING gist(during)• ALTER TABLE schedule ADD EXCLUDE USING gist (during WITH &&)ERROR: conflicting key value violates exclusion constraint”schedule_during_excl”DETAIL: Key (during)=([ 2010-01-01 14:45:00, 2010-01-0115:45:00 )) conflicts with existing key (during)=([ 2010-01-0114:30:00, 2010-01-01 15:30:00 )).
Datatypes: hstore• properties– {“author” => “John Grisham”, “pages” => 535}– {“director” => “Jon Favreau”, “runtime” = 126}• SELECT … FROM mytableWHERE properties -> ‘director’ LIKE ‘%Favreau’– Does not use an index• WHERE properties @> (‘author’ LIKE “%Grisham”)– Uses an index to only check properties with an ‘author’• CREATE INDEX table_properties ON mytable USING gin(properties)
Datatypes: arrays• CREATE TABLE sal_emp(name text, pay_by_quarter integer[],schedule text[][])• CREATE TABLE tictactoe ( squares integer[3][3] )• INSERT INTO tictactoe VALUES (‘{{1,2,3},{4,5,6},{7,8,9}}’)• SELECT squares[1:2][1:1] == {{1},{4}}• SELECT squares[2:3][2:3] == {{5,6},{8,9}}
Datatypes: JSON• Validate JSON structure• Convert row to JSON• Functions and operators very similar to hstore
Datatypes: XML• Validates well-formed XML• Stores like a TEXT field• XML operations like Xpath• Can’t index XML column but you can index theresult of an Xpath function
Data compression with TOAST• TOAST = The Oversized Attribute Storage Technique• TOASTable data is automatically TOASTed• Example:– stored a 2.2m XML document– storage size was 81k
User created datatypes• Built in types– Numerics, monetary, binary, time, date, interval, boolean,enumerated, geometric, network address, bit string, text search, UUID,XML, JSON, array, composite, range– Add-ons for more such as UPC, ISBN and more• Create your own types– Address (contains 2 streets, city, state, zip, country)– Define how your datatype is indexed– GIN and GiST indexes are used by custom datatypes
Further exploration: PostGIS• Adds Geographic datatypes• Distance, area, union, intersection, perimeter• Spatial indexes• Tools to load available geographic data• Distance, Within, Overlaps, Touches, Equals,Contains, Crosses• SELECT name, ST_AsText(geom)FROM nyc_subway_stationsWHERE name = ‘Broad St’• SELECT name, boronameFROM nyc_neighborhoodsWHERE ST_Intersects(geom,ST_GeomFromText(‘POINT(583571 4506714)’,26918)• SELECT sub.name, nh.name, nh.boroughFROM nyc_neighborhoods AS nhJOIN nyc_subway_stations AS subON ST_Contains(nh.geom, sub.geom)WHERE sub.name = ‘Broad St”
Further exploration: Functions• Can be used in queries• Can be used in stored procedures and triggers• Can be used to build indexes• Can be used as table defaults• Can be written in PL/pgSQL, PL/Tcl, PL/Perl,PL/Python out of the box• PL/V8 is available an an extension to useJavascript
Further exploration: PLV8• CREATE OR REPLACE FUNCTION plv8_test(keys text[], vals text[])RETURNS text AS $$var o = {};for(var i = 0; i < keys.length; i++) {o[keys[i]] = vals[i];}return JSON.stringify(o);$$ LANGUAGE plv8 IMMUTABLE STRICT;SELECT plv8_test(ARRAY[‘name’,’age’],ARRAY[‘Tom’,’29’]);• CREATE TYPE rec AS (i integer, t text);CREATE FUNCTION set_of_records RETURNS SETOF rec AS $$plv8.return_next({“i”: 1,”t”: ”a”});plv8.return_next({“i”: 2,”t”: “b”});$$ LANGUAGE plv8;SELECT * FROM set_of_records();
Further exploration: Async commands/ indexes• Fine grained control within functions– PQsendQuery– PQsendQueryParams– PQsendPrepare– PQsendQueryPrepared– PQsendDescribePrepared– PQgetResult– PQconsumeInput• Per connection asynchronous commits– set synchronous_commit = off• Concurrent index creation to avoid blocking large tables– CREATE INDEX CONCURRENTLY big_index ON mytable (things)
ARCHITECTUREAnd finally…
Biggest Issue with Frameworks• Framework Dependency• Trying to do everything in application code• Race conditions• Package dependency
Old School• Service Oriented Architecture– Getting more popular because of REST– Had been happening for years prior with WSDL• Database managed your data– Constraints, triggers, functions, stored procedures– If it was in the database…it was valid• Nothing has changed…this is still the best way
If you really leverage your database…• You can easily break your application intological parts• You don’t need to create APIs through yourcore code base when direct DB access there• You can use a different language for certainthings if it makes sense to do so– Node.js is great for APIs– Using a library that only runs on Windows• Database can provide granular access controls
Architecture: Before
Architecture: After
Architecture: Scaled
THANKS!
Credits / Sources• NOTE: Some code samples in this presentation have minor alterations forpresentation clarity (such as leaving out dictionary specifications on somesearch calls, etc)• http://www.postgresql.org/docs/9.2/static/index.html• http://workshops.opengeo.org/postgis-intro/• http://stackoverflow.com/questions/15983152/how-can-i-find-out-how-big-a-large-text-field-is-in-postgres• https://devcenter.heroku.com/articles/heroku-postgres-extensions-postgis-full-text-search• http://railscasts.com/episodes/345-hstore?view=asciicast• http://www.slideshare.net/billkarwin/full-text-search-in-postgresql• http://sourceforge.net/apps/mediawiki/postgres-xc/index.php?title=Main_Page• http://railscasts.com/episodes/151-rack-middleware• http://joshrendek.com/2012/11/sidekiq-vs-resque/• http://torquebox.org/news/2011/10/06/torquebox-2x-performance/• http://jruby.org/• https://rvm.io/• http://ddollar.github.io/foreman/• http://en.wikipedia.org/wiki/Ruby_(programming_language)• http://bundler.io/• http://www.techempower.com/benchmarks/#section=data-r9&hw=peak&test=json

Recommended

PDF
Ruby on Rails Presentation
PDF
Intro to Crystal Programming Language
PDF
Crystal
PDF
2016-05-12 DCRUG React.rb
PPT
Rails Vs CakePHP
PDF
A brief intro to RubyMotion
PDF
Dsl로 만나는 groovy
PPSX
Webpack & EcmaScript 6 (Webelement #32)
 
PPTX
Introduction to go lang
PDF
Groovy android
PDF
Buildr - build like you code
PPTX
Ruby programming
PDF
Spring-batch Groovy y Gradle
PPTX
Geb+spock: let your functional tests live long and prosper
PDF
Use groovy & grails in your spring boot projects
PPTX
Hack Rio/OS
PDF
Por que Rails?
KEY
Introduction To Grails
PDF
Golang #5: To Go or not to Go
PDF
Groovy and noteworthy
PDF
really really really awesome php application with bdd behat and iterfaces
PDF
Angular Vienna - Use React tools for better Angular apps
PDF
Crystal internals (part 1)
KEY
Groovy & Grails
PDF
Building Command Line Tools with Golang
PDF
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
PPTX
Building Apis in Scala with Playframework2
PDF
Developing for LinkedIn's Application Platform
PDF
ES2015 / ES6: Basics of modern Javascript
PDF
ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes,...

More Related Content

PDF
Ruby on Rails Presentation
PDF
Intro to Crystal Programming Language
PDF
Crystal
PDF
2016-05-12 DCRUG React.rb
PPT
Rails Vs CakePHP
PDF
A brief intro to RubyMotion
PDF
Dsl로 만나는 groovy
PPSX
Webpack & EcmaScript 6 (Webelement #32)
 
Ruby on Rails Presentation
Intro to Crystal Programming Language
Crystal
2016-05-12 DCRUG React.rb
Rails Vs CakePHP
A brief intro to RubyMotion
Dsl로 만나는 groovy
Webpack & EcmaScript 6 (Webelement #32)
 

What's hot

PPTX
Introduction to go lang
PDF
Groovy android
PDF
Buildr - build like you code
PPTX
Ruby programming
PDF
Spring-batch Groovy y Gradle
PPTX
Geb+spock: let your functional tests live long and prosper
PDF
Use groovy & grails in your spring boot projects
PPTX
Hack Rio/OS
PDF
Por que Rails?
KEY
Introduction To Grails
PDF
Golang #5: To Go or not to Go
PDF
Groovy and noteworthy
PDF
really really really awesome php application with bdd behat and iterfaces
PDF
Angular Vienna - Use React tools for better Angular apps
PDF
Crystal internals (part 1)
KEY
Groovy & Grails
PDF
Building Command Line Tools with Golang
PDF
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
PPTX
Building Apis in Scala with Playframework2
PDF
Developing for LinkedIn's Application Platform
Introduction to go lang
Groovy android
Buildr - build like you code
Ruby programming
Spring-batch Groovy y Gradle
Geb+spock: let your functional tests live long and prosper
Use groovy & grails in your spring boot projects
Hack Rio/OS
Por que Rails?
Introduction To Grails
Golang #5: To Go or not to Go
Groovy and noteworthy
really really really awesome php application with bdd behat and iterfaces
Angular Vienna - Use React tools for better Angular apps
Crystal internals (part 1)
Groovy & Grails
Building Command Line Tools with Golang
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
Building Apis in Scala with Playframework2
Developing for LinkedIn's Application Platform

Viewers also liked

PDF
ES2015 / ES6: Basics of modern Javascript
PDF
ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes,...
PPTX
PostgreSQL - It's kind've a nifty database
PPTX
Day 1 - Intro to Ruby
PPTX
Repeating History...On Purpose...with Elixir
PPTX
Go from a PHP Perspective
PPTX
Pair Programming - the lightning talk
ES2015 / ES6: Basics of modern Javascript
ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes,...
PostgreSQL - It's kind've a nifty database
Day 1 - Intro to Ruby
Repeating History...On Purpose...with Elixir
Go from a PHP Perspective
Pair Programming - the lightning talk

Similar to Exploring Ruby on Rails and PostgreSQL

PDF
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
KEY
Ruby On Rails
PDF
TorqueBox at DC:JBUG - November 2011
KEY
Why ruby and rails
PPTX
Ruby on Rails - An overview
PPT
Ruby On Rails
KEY
Ruby On Rails Overview
PDF
Web Development using Ruby on Rails
PDF
Ruby and Rails short motivation
 
PDF
rubyonrails
PDF
rubyonrails
KEY
Wider than rails
PDF
JRuby and Google App Engine
KEY
Ruby on Rails survival guide of an aged Java developer
PDF
Rails - getting started
PPT
Ruby on Rails (RoR) as a back-end processor for Apex
PDF
TorqueBox
PPTX
Rubyonrails 120409061835-phpapp02
KEY
TorqueBox - Ruby Hoedown 2011
PDF
TorqueBox for Rubyists
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby On Rails
TorqueBox at DC:JBUG - November 2011
Why ruby and rails
Ruby on Rails - An overview
Ruby On Rails
Ruby On Rails Overview
Web Development using Ruby on Rails
Ruby and Rails short motivation
 
rubyonrails
rubyonrails
Wider than rails
JRuby and Google App Engine
Ruby on Rails survival guide of an aged Java developer
Rails - getting started
Ruby on Rails (RoR) as a back-end processor for Apex
TorqueBox
Rubyonrails 120409061835-phpapp02
TorqueBox - Ruby Hoedown 2011
TorqueBox for Rubyists

More from Barry Jones

PPTX
What's the "right" PHP Framework?
PPT
Protecting Users from Fraud
PPTX
Day 8 - jRuby
PPTX
Day 2 - Intro to Rails
PPTX
Day 9 - PostgreSQL Application Architecture
PPTX
Day 7 - Make it Fast
PPTX
AWS re:Invent 2013 Recap
PPTX
Day 4 - Models
PPTX
Day 6 - PostGIS
What's the "right" PHP Framework?
Protecting Users from Fraud
Day 8 - jRuby
Day 2 - Intro to Rails
Day 9 - PostgreSQL Application Architecture
Day 7 - Make it Fast
AWS re:Invent 2013 Recap
Day 4 - Models
Day 6 - PostGIS

Recently uploaded

PPTX
Coded Agents – with UiPath SDK + LangGraph [Virtual Hands-on Workshop]
PDF
Vibe Coding vs. Spec-Driven Development [Free Meetup]
PPTX
Cloud-and-AI-Platform-FY26-Partner-Playbook.pptx
PDF
Security Forum Sessions from Houston 2025 Event
PDF
Real-Time Data Insight Using Microsoft Forms for Business
PDF
Session 1 - Solving Semi-Structured Documents with Document Understanding
PDF
December Patch Tuesday
 
PDF
Our Digital Tribe_ Cultivating Connection and Growth in Our Slack Community 🌿...
PDF
Making Sense of Raster: From Bit Depth to Better Workflows
PDF
Access Control 2025: From Security Silo to Software-Defined Ecosystem
PPTX
Unit-4-ARTIFICIAL NEURAL NETWORKS.pptx ANN ppt Artificial neural network
PDF
Is It Possible to Have Wi-Fi Without an Internet Provider
PPTX
From Backup to Resilience: How MSPs Are Preparing for 2026
 
PPT
software-security-intro in information security.ppt
PPTX
cybercrime in Information security .pptx
PPTX
Cybercrime in the Digital Age: Risks, Impact & Protection
PPTX
Building Cyber Resilience for 2026: Best Practices for a Secure, AI-Driven Bu...
PPTX
Protecting Data in an AI Driven World - Cybersecurity in 2026
PPTX
Chapter 3 Introduction to number system.pptx
PPTX
Cybersecurity Best Practices - Step by Step guidelines
Coded Agents – with UiPath SDK + LangGraph [Virtual Hands-on Workshop]
Vibe Coding vs. Spec-Driven Development [Free Meetup]
Cloud-and-AI-Platform-FY26-Partner-Playbook.pptx
Security Forum Sessions from Houston 2025 Event
Real-Time Data Insight Using Microsoft Forms for Business
Session 1 - Solving Semi-Structured Documents with Document Understanding
December Patch Tuesday
 
Our Digital Tribe_ Cultivating Connection and Growth in Our Slack Community 🌿...
Making Sense of Raster: From Bit Depth to Better Workflows
Access Control 2025: From Security Silo to Software-Defined Ecosystem
Unit-4-ARTIFICIAL NEURAL NETWORKS.pptx ANN ppt Artificial neural network
Is It Possible to Have Wi-Fi Without an Internet Provider
From Backup to Resilience: How MSPs Are Preparing for 2026
 
software-security-intro in information security.ppt
cybercrime in Information security .pptx
Cybercrime in the Digital Age: Risks, Impact & Protection
Building Cyber Resilience for 2026: Best Practices for a Secure, AI-Driven Bu...
Protecting Data in an AI Driven World - Cybersecurity in 2026
Chapter 3 Introduction to number system.pptx
Cybersecurity Best Practices - Step by Step guidelines

Exploring Ruby on Rails and PostgreSQL

  • 1.
    Exploring Ruby onRailsand PostgreSQL
  • 2.
    Who am I?•I’m Barry Jones• Application Developer since ’98– Java, PHP, Groovy, Ruby, Perl, Python– MySQL, PostgreSQL, SQL Server, Oracle, MongoDB• Efficiency and infrastructure nut• Believer in “right tool for the job”– There is no silver bullet, programming is abouttradeoffs
  • 3.
    The Silver BulletRubyon Rails and PostgreSQLj/k But it’s close
  • 4.
    What do welook for in a language?• Balance– Can it do what I need it to do?• Web: Ruby/Python/PHP/Perl/Java/C#/C/C++– Efficient to develop with it?• Ruby/Python/PHP– Libraries/tools/ecosystem to avoid reinventing the wheel?• Ruby/Python/PHP/Java/Perl– Is it fast?• Ruby/Python/Java/C#/C/C++– Is it stable?• Ruby/Python/PHP/Perl/Java/C#/C/C++– Do other developers use it?• At my company? In the area? Globally?– Cost effective?• Ruby/Python/PHP/Perl/C/C++– Can it handle my architectural approach well?• Ruby/Python/Java/C# handle just about everything• CGI languages (PHP/Perl/C/C++) are very bad fits for frameworks, long polling, evented programming– Will it scale?• Yes. This is a subjective question because web servers scale horizontally naturally– Will my boss let me use it?• .NET shop? C#• Java shop? Java (Groovy, Clojure, Scala), jRuby, jython• *nix shop? Ruby, Python, Perl, PHP, C, C++• Probable Winners: Ruby and Python
  • 5.
    What stands outabout Ruby?• Malleability– Everything is an object– Objects can be monkeypatched• Great for writingDomain SpecificLanguages– Puppet– Chef– Capistrano– Rails“this is a string object”.lengthclass Stringdef palindrome?self == self.reverseendend“radar”.palindrome?
  • 6.
    How is monkeypatching good?• Rails adds web specific capabilities to Ruby– “ “.blank? == true• Makes using 3rd party libraries much easier– Aspect Oriented Development• Not dependent on built in hooks– Queued processingrecord = Record.find(id)record.delay.some_intense_logic• DelayedJob• Resque• Sidekiq• Stalker– Cross integrationsEmail.deliver• MailHopper – Automatically deliver all email in the background• Gems that specifically enhance other gems
  • 7.
    How is monkeypatching…bad?• If any behavior is modified by a monkey patchthere is a chance something will break• On a positive note, if you’re writing tests andfollowing TDD or BDD the tests should catchany problems• On another positive note, the ruby communityis very big on testing
  • 8.
    Why was Rubycreated?• Created by Yukirio Matsumoto• "I wanted a scripting language that was morepowerful than Perl, and more object-orientedthan Python.”• "I hope to see Ruby help every programmer inthe world to be productive, and to enjoyprogramming, and to be happy. That is theprimary purpose of Ruby language.”– Google Tech Talk in 2008
  • 9.
    Ruby Version Manager•cd into directoryautoselects correctversion of ruby andgemset• Makes running multipleprojects with multipleversions of ruby andgem dependencies onone machine deadsimple.rvmrc filervm rubytype-version-patch@gemsetExamples:rvm ruby-1.9.3-p327@myprojectrvm jruby-1.7.4@myjrubyprojectrvm ree-1.8.7@oldproject
  • 10.
    Bundler and Gemfile$bundle installUsing rake (10.0.4)Using i18n (0.6.1)Using multi_json (1.7.2)Using activesupport (3.2.13)Using builder (3.0.4)Using activemodel (3.2.13)Using erubis (2.7.0)Using journey (1.0.4)Using rack (1.4.5)Using rack-cache (1.2)Using rack-test (0.6.2)…Your bundle is complete! Use `bundle show[gemname]` to see where a bundled gem isinstalled.source 'https://rubygems.org'source 'http://gems.github.com'# Application infrastructuregem 'rails', '3.2.13'gem 'devise'gem 'simple_form'gem 'slim'gem 'activerecord-jdbc-adapter’gem 'activerecord-jdbcpostgresql-adapter'gem 'jdbc-postgres'gem 'jruby-openssl'gem 'jquery-rails'gem 'torquebox', '2.3.0'gem 'torquebox-server', '~> 2.3.0'
  • 11.
    ForemanNot Ruby specificbut written in rubyUsed with HerokuDrop in a Procfile$ foreman start CTRL + C to stop everythingProcfileweb: bundle exec thin start -p $PORTworker: bundle exec rake resque:work QUEUE=*clock: bundle exec rake resque:scheduler
  • 12.
    jRuby: Why?Ruby isn’tperfect• Some gems can create memory leaks– esp. if they were written with native C• Does not have kernel level threading– Global Interpreter Lock• Everything is an object means unnecessaryprocessing happens when doing things likeadding numbers leading to a performance hit
  • 13.
    jRuby: So howdoes it fix things?I hate writing Java…but the JVM is a work of art• Java infrastructure is virtually bulletproof– Most mature way to deploy a web application– Enterprisey • JVM’s garbage collector is best of breed and eliminates the potentialmemory leak issues• JVM’s Just-In-Time compiler continually optimizes code the longer it runsmaking it faster• JVM gives Ruby kernel level threading• jRuby inspects your Ruby code to see if you’re doing anything it wouldprefer you didn’t…and turns it off if you’re not– Eg. If you aren’t overloading the + operator on int’s, it will convert them tobasic types instead of running as objects• Include and use very mature Java libraries directly in your Ruby code– Significantly expands your toolbelt– Allows easy integration into existing Java environments
  • 14.
    The Sidekiq TestSidekiqis a multithreaded backgroundworker that provides tremendousconcurrency benefitsCreating 1,000,000 objects in 50concurrent threadsRubyjRuby
  • 15.
    The App ServerTestCPU Usage
  • 16.
    The App ServerTestFree Memory
  • 17.
    The App ServerTestLatency
  • 18.
    The App ServerTestThroughput
  • 19.
    Update and Clarification•As of this posting to Slideshare, Torquebox has a mature version 3and a prototype version 4 that operates in a “web server only”mode. Ruby is at version 2.1.0 with dramatic improvements tomemory performance with forking which allows higherconcurrency.• At this time, jruby still wins but it’s much closer. Based on chatterfrom the #jruby IRC channels, a major new release of both jRubyand Torquebox are expected to dramatically improve theirperformance thanks to recent Java updates. The expected timelinewas late 2014 last I heard.• Independent benchmarks can be found here:http://www.techempower.com/benchmarks/#section=data-r9&hw=peak&test=json
  • 20.
    RUBY ON RAILSLet’stake a break before covering…
  • 21.
    What do welook for in a framework?• Please don’t suck– Rails does not suck• Does it follow Model-View-Controller?– Yes– Since Rails 1 it’s been the standard bearer for how to do MVC on the web, copied in almost every language• Does it help me avoid repeating myself (DRY)?– Yes• Is it self documenting?– Yes, it has a set of rules that generally make most documentation unnecessary• Is it flexible enough to bend to my application needs?– Yes• Do other people use it?– Good gosh yes• Will it work with my database?– Yes• Is it still going to be around in X years?– Ruby has Rails– Python has Django– Groovy has Grails– C# has MVC– PHP has fragmented framework Hell (aka – who knows?)– Java has a few major players (Struts 2, Play, etc)
  • 22.
  • 23.
    Rails: RackWatch thisexcellent walkthrough of RackMiddleware:http://railscasts.com/episodes/151-rack-middlewareSummary:It’s a layer of ruby code that passes requests into your app andsends responses back out. You can add layers to do pre/postprocessing on all requests prior to beginning ANY of yourapplication code.
  • 24.
    Rails: Models /ActiveRecordclass Post < ActiveRecord::Basebelongs_to :categoryhas_many :tags, through: :posts_tagsvalidates :title, presence: truebefore_save :create_slug, only: :createscope :newest_first, order(‘created_at DESC’)scope :active, where(‘active = ?’,true)scope :newest_active, newest_first.activescope :search, lambda do |text|where(‘title LIKE ?’,”%#{text}%”)enddef create_slugself.slug = title.downcase.squish.sub(‘ ‘,’-’)endendpost = Post.new(title: ‘Some title’)post.save!ORpost = Post.create(title: ‘Some title’)post.slug # some-titlepost.id # 1post.created_at # Created datetimepost.updated_at # Updated datetimepost.title = ‘New title’post.save!# Relationspost.tags.firstpost.tags.countpost.category.namepost = Post.include(:tags) # Eager loadpost =Post.search(‘some’).newest_active.first
  • 25.
    Rails: Migrationsclass CreateInitialTables< ActiveRecord::Migrationdef upcreate_table :posts do |t|t.string :titlet.text :bodyt.string :slugt.integer :category_idt.timestampsend# … create more tables…add_index :tags, [:name,:something], unique: trueexecute “UPDATE posts SET field = ‘value’ WHERE stuff = ‘happens’”enddef downdrop_table :postsenddef changeadd_column :posts, :user_id, :integerendend$ rake db:migrate
  • 26.
    Rails: ControllersClass PostsController< ApplicationControllerbefore_filter :authenticate, only: :destroydef index # GET /postsenddef new # GET /posts/newenddef create # POST /postsenddef show # GET /posts/:idenddef edit # GET /posts/:id/editenddef update # PUT /posts/:idenddef destroy # DELETE /posts/:idendend# Routesresources :postsOR limit itresources :posts, only: [:create,:new]
  • 27.
    Rails: Views/app/views/layouts/application.html.erb/posts/new.html.slim/new.json.rabl/index.xml.erb/_widget.html.erb# slimexample.posth2=post.title.body.grid-8=post.body# erb example<div class=“post”><h2><%=post.title%></h2><div class=“body grid-8”><%=post.body%></div></div>
  • 28.
    Rails: Testing withrspecDescribe Post dodescribe ‘a basic test’ dosubject { FactoryGirl.build(:post,title: ‘Some title’) }it ‘should be valid’ doshould_not be_nilsubject.valid?.should be_trueendenddescribe ‘something with a complicated dependency’ dobefore doPost.stub(:function_to_override){ true }endenddescribe ‘a test with API hits’ douse_vcr_cassette ‘all_a_twitter’, record: :new_episodesendend
  • 29.
    POSTGRESQLLet’s take abreak before we talk about…
  • 30.
    How do youpronounce it?Answer Response Percentagepost-gres-q-l 2379 45%post-gres 1611 30%pahst-grey 24 0%pg-sequel 50 0%post-gree 350 6%postgres-sequel 574 10%p-g 49 0%database 230 4%Total 5267
  • 31.
    What IS PostgreSQL?•Fully ACID compliant• Feature rich and extensible• Fast, scalable and leverages multicoreprocessors very well• Enterprise class with quality corporatesupport options• Free as in beer• It’s kind’ve nifty
  • 32.
    Laundry List ofFeatures• Multi-version Concurrency Control (MVCC)• Point in Time Recovery• Tablespaces• Asynchronous replication• Nested Transactions• Online/hot backups• Genetic query optimizer multiple index types• Write ahead logging (WAL)• Internationalization: character sets, locale-aware sorting, case sensitivity,formatting• Full subquery support• Multiple index scans per query• ANSI-SQL:2008 standard conformant• Table inheritance• LISTEN / NOTIFY event system• Ability to make a Power Point slide run out of room
  • 33.
    What are wecovering today?• Full text-search• Built in data types• User defined data types• Automatic data compression• A look at some other cool features andextensions, depending how we’re doing ontime
  • 34.
    Full-text Search• Whatabout…?– Solr– Elastic Search– Sphinx– Lucene– MySQL• All have their purpose– Distributed search of multiple document types• Sphinx– Client search performance is all that matters• Solr– Search constantly incoming data withstreaming index updates• Elastic Search excels– You really like Java• Lucene– You want terrible search results that don’t evenmake sense to you much less your users• MySQL full text search = the worst thing in the world
  • 35.
    Full-text Search• Complicationsof stand alone search engines– Data synchronization• Managing deltas, index updates• Filtering/deleting/hiding expired data• Search server outages, redundancy– Learning curve– Character sets match up with my database?– Additional hardware / servers just for search– Can feel like a black box when you get a supportquestion asking “why is/isn’t this showing up?”
  • 36.
    Full-text Search• Butwhat if your needs are more like:– Search within my database– Avoid syncing data with outside systems– Avoid maintaining outside systems– Less black box, more control
  • 37.
    Full-text Search• tsvector–The text to be searched• tsquery– The search query• to_tsvector(‘the church is AWESOME’) @@ to_tsquery(SEARCH)• @@ to_tsquery(‘church’) == true• @@ to_tsquery(‘churches’) == true• @@ to_tsquery(‘awesome’) == true• @@ to_tsquery(‘the’) == false• @@ to_tsquery(‘churches & awesome’) == true• @@ to_tsquery(‘church & okay’) == false• to_tsvector(‘the church is awesome’)– 'awesom':4 'church':2• to_tsvector(‘simple’,’the church is awesome’)– 'are':3 'awesome':4 'church':2 'the':1
  • 38.
    Full-text Search• ALTERTABLE mytable ADD COLUMN search_vector tsvector• UPDATE mytableSET search_vector = to_tsvector(‘english’,coalesce(title,’’) || ‘ ‘ ||coalesce(body,’’) || ‘ ‘ || coalesce(tags,’’))• CREATE INDEX search_text ON mytable USING gin(search_vector)• SELECT some, columns, we, needFROM mytableWHERE search_vector @@ to_tsquery(‘english’,‘Jesus & awesome’)ORDER BY ts_rank(search_vector,to_tsquery(‘english’,‘Jesus & awesome’))DESC• CREATE TRIGGER search_update BEFORE INSERT OR UPDATEON mytable FOR EACH ROW EXECUTE PROCEDUREtsvector_update_trigger(search_vector, ’english’, title, body, tags)
  • 39.
    Full-text Search• CREATEFUNCTION search_trigger RETURNS trigger AS $$beginnew.search_vector :=setweight(to_tsvector(‘english’,coalesce(new.title,’’)),’A’) ||setweight(to_tsvector(‘english’,coalesce(new.body,’’)),’D’) ||setweight(to_tsvector(‘english’,coalesce(new.tags,’’)),’B’);return new;end$$ LANGUAGE plpgsql;• CREATE TRIGGER search_vector_updateBEFORE INSERT OR UPDATE OF title, body, tags ON mytableFOR EACH ROW EXECUTE PROCEDURE search_trigger();
  • 40.
    Full-text Search• Avariety of dictionaries– Various Languages– Thesaurus– Snowball, Stem, Ispell, Synonym– Write your own• ts_headline– Snippet extraction and highlighting
  • 41.
    Datatypes: ranges• int4range,int8range, numrange, tsrange, tstzrange, daterange• SELECT int4range(10,20) @> 3 == false• SELECT numrange(11.1,22.2) && numrange(20.0,30.0) == true• SELECT int4range(10,20) * int4range(15,25) == 15-20• CREATE INDEX res_index ON schedule USING gist(during)• ALTER TABLE schedule ADD EXCLUDE USING gist (during WITH &&)ERROR: conflicting key value violates exclusion constraint”schedule_during_excl”DETAIL: Key (during)=([ 2010-01-01 14:45:00, 2010-01-0115:45:00 )) conflicts with existing key (during)=([ 2010-01-0114:30:00, 2010-01-01 15:30:00 )).
  • 42.
    Datatypes: hstore• properties–{“author” => “John Grisham”, “pages” => 535}– {“director” => “Jon Favreau”, “runtime” = 126}• SELECT … FROM mytableWHERE properties -> ‘director’ LIKE ‘%Favreau’– Does not use an index• WHERE properties @> (‘author’ LIKE “%Grisham”)– Uses an index to only check properties with an ‘author’• CREATE INDEX table_properties ON mytable USING gin(properties)
  • 43.
    Datatypes: arrays• CREATETABLE sal_emp(name text, pay_by_quarter integer[],schedule text[][])• CREATE TABLE tictactoe ( squares integer[3][3] )• INSERT INTO tictactoe VALUES (‘{{1,2,3},{4,5,6},{7,8,9}}’)• SELECT squares[1:2][1:1] == {{1},{4}}• SELECT squares[2:3][2:3] == {{5,6},{8,9}}
  • 44.
    Datatypes: JSON• ValidateJSON structure• Convert row to JSON• Functions and operators very similar to hstore
  • 45.
    Datatypes: XML• Validateswell-formed XML• Stores like a TEXT field• XML operations like Xpath• Can’t index XML column but you can index theresult of an Xpath function
  • 46.
    Data compression withTOAST• TOAST = The Oversized Attribute Storage Technique• TOASTable data is automatically TOASTed• Example:– stored a 2.2m XML document– storage size was 81k
  • 47.
    User created datatypes•Built in types– Numerics, monetary, binary, time, date, interval, boolean,enumerated, geometric, network address, bit string, text search, UUID,XML, JSON, array, composite, range– Add-ons for more such as UPC, ISBN and more• Create your own types– Address (contains 2 streets, city, state, zip, country)– Define how your datatype is indexed– GIN and GiST indexes are used by custom datatypes
  • 48.
    Further exploration: PostGIS•Adds Geographic datatypes• Distance, area, union, intersection, perimeter• Spatial indexes• Tools to load available geographic data• Distance, Within, Overlaps, Touches, Equals,Contains, Crosses• SELECT name, ST_AsText(geom)FROM nyc_subway_stationsWHERE name = ‘Broad St’• SELECT name, boronameFROM nyc_neighborhoodsWHERE ST_Intersects(geom,ST_GeomFromText(‘POINT(583571 4506714)’,26918)• SELECT sub.name, nh.name, nh.boroughFROM nyc_neighborhoods AS nhJOIN nyc_subway_stations AS subON ST_Contains(nh.geom, sub.geom)WHERE sub.name = ‘Broad St”
  • 49.
    Further exploration: Functions•Can be used in queries• Can be used in stored procedures and triggers• Can be used to build indexes• Can be used as table defaults• Can be written in PL/pgSQL, PL/Tcl, PL/Perl,PL/Python out of the box• PL/V8 is available an an extension to useJavascript
  • 50.
    Further exploration: PLV8•CREATE OR REPLACE FUNCTION plv8_test(keys text[], vals text[])RETURNS text AS $$var o = {};for(var i = 0; i < keys.length; i++) {o[keys[i]] = vals[i];}return JSON.stringify(o);$$ LANGUAGE plv8 IMMUTABLE STRICT;SELECT plv8_test(ARRAY[‘name’,’age’],ARRAY[‘Tom’,’29’]);• CREATE TYPE rec AS (i integer, t text);CREATE FUNCTION set_of_records RETURNS SETOF rec AS $$plv8.return_next({“i”: 1,”t”: ”a”});plv8.return_next({“i”: 2,”t”: “b”});$$ LANGUAGE plv8;SELECT * FROM set_of_records();
  • 51.
    Further exploration: Asynccommands/ indexes• Fine grained control within functions– PQsendQuery– PQsendQueryParams– PQsendPrepare– PQsendQueryPrepared– PQsendDescribePrepared– PQgetResult– PQconsumeInput• Per connection asynchronous commits– set synchronous_commit = off• Concurrent index creation to avoid blocking large tables– CREATE INDEX CONCURRENTLY big_index ON mytable (things)
  • 52.
  • 53.
    Biggest Issue withFrameworks• Framework Dependency• Trying to do everything in application code• Race conditions• Package dependency
  • 54.
    Old School• ServiceOriented Architecture– Getting more popular because of REST– Had been happening for years prior with WSDL• Database managed your data– Constraints, triggers, functions, stored procedures– If it was in the database…it was valid• Nothing has changed…this is still the best way
  • 55.
    If you reallyleverage your database…• You can easily break your application intological parts• You don’t need to create APIs through yourcore code base when direct DB access there• You can use a different language for certainthings if it makes sense to do so– Node.js is great for APIs– Using a library that only runs on Windows• Database can provide granular access controls
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
    Credits / Sources•NOTE: Some code samples in this presentation have minor alterations forpresentation clarity (such as leaving out dictionary specifications on somesearch calls, etc)• http://www.postgresql.org/docs/9.2/static/index.html• http://workshops.opengeo.org/postgis-intro/• http://stackoverflow.com/questions/15983152/how-can-i-find-out-how-big-a-large-text-field-is-in-postgres• https://devcenter.heroku.com/articles/heroku-postgres-extensions-postgis-full-text-search• http://railscasts.com/episodes/345-hstore?view=asciicast• http://www.slideshare.net/billkarwin/full-text-search-in-postgresql• http://sourceforge.net/apps/mediawiki/postgres-xc/index.php?title=Main_Page• http://railscasts.com/episodes/151-rack-middleware• http://joshrendek.com/2012/11/sidekiq-vs-resque/• http://torquebox.org/news/2011/10/06/torquebox-2x-performance/• http://jruby.org/• https://rvm.io/• http://ddollar.github.io/foreman/• http://en.wikipedia.org/wiki/Ruby_(programming_language)• http://bundler.io/• http://www.techempower.com/benchmarks/#section=data-r9&hw=peak&test=json

Editor's Notes

  • #23 This is a bad diagram because I tried to use the built in tools in power point. I need to update it. In reality the View arrow should be going back through Rack to the Browser.

[8]ページ先頭

©2009-2025 Movatter.jp