painless ruby deployment on shelly cloud
DESCRIPTION
TRANSCRIPT
![Page 1: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/1.jpg)
Shelly Cloud
Painless Ruby deploymentGiedrius Rimkus
2012 July
![Page 2: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/2.jpg)
Cloud Computing?
Pay-per-useOn-demandComputing resources
![Page 3: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/3.jpg)
Alternatives?
EngineYard http://www.engineyard.comHeroku http://www.heroku.comScalarium http://www.scalarium.comothers..
![Page 4: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/4.jpg)
What Shelly Cloud is?
Delivering platform as a service
Deployments are done by pushing with git
![Page 5: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/5.jpg)
Example of git pushgiedrius@rubylt:~/Projects/store (master) $ git push gstore masterCounting objects: 81, done.Delta compression using up to 4 threads.Compressing objects: 100% (72/72), done.Writing objects: 100% (81/81), 27.62 KiB, done.Total 81 (delta 6), reused 0 (delta 0)remote:remote: ---> Received push to cloud 'gstore'remote: ---> Checking Gemfileremote: ---> Push acceptedremote: ---> Start your cloud using: `shelly start --cloud gstore`remote:To [email protected]:gstore.git* [new branch] master -> master
![Page 6: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/6.jpg)
Aim
Helping developersDevelopers focus on building application and not on deployment nor infrastructure
![Page 7: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/7.jpg)
Requirements
- Ruby versions● MRI Ruby (1.9.3)● MRI Ruby (1.9.2)● Ruby Enterprise Edition (1.8.7)
- Bundler- "shelly-dependencies" gem (optional)- Rails 3.x support- Rails 2.3.x support- Rack-based apps- Gems with native extensions
https://shellycloud.com/documentation/requirements
![Page 8: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/8.jpg)
Shelly Cloud
○ Running Ruby applications○ It doesn't have to be Rails application
○ Sinatra○ or any other which is compatible with Rack
interface
full list of supported frameworks https://github.com/rack/rack#supported-web-frameworks
![Page 9: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/9.jpg)
Shelly Gem
A tool for managing clouds on Shelly Cloud from command line.
![Page 10: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/10.jpg)
Cloudfile
Your cloud management place
You can edit settings of your Cloud by making changes to the Cloudfile, committing them to the git repository and pushing those changes to the shelly git remote.
![Page 11: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/11.jpg)
Features
○ Running periodic tasks○ Background processing○ Storing Files○ Caching (frontend, backend)○ Sending emails○ SSL support○ Websockets support
![Page 12: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/12.jpg)
Running periodic tasks
Cron job is a periodic taskWhenever
Modify Clouldfile
1. Add whenever to Gemfilegem "whenever"
2. Run bundle3. $ bundle exec wheneverize .4. define cronjobs in config/schedule.rb
env :MAILTO, "[email protected]"
![Page 13: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/13.jpg)
Background processing
Delayed_jobs gem is used for this task.Set up one of your apps for delayed_jobsAdd it to your GemfileAdd jobs*Commit and push (deploy)
* https://github.com/collectiveidea/delayed_job/blob/master
![Page 14: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/14.jpg)
Storing files
Kind of sharing files between instances and deployments
For exampleuploads/
![Page 15: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/15.jpg)
Caching
Frontend caching using VarnishBackend caching using Memcache.
● cache is cleared after every deploy.
![Page 16: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/16.jpg)
Sending emails
Sending emails works out of the boxSPF record (trusted mails)1 mail server IP
![Page 17: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/17.jpg)
SSL Support
When using domain code-name.shellyapp.com you get free SSL.
If you want own SSL, you will have to purchase SSL certificate from any CA as well as private IP from Shelly Cloud.
![Page 18: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/18.jpg)
Websockets
You can run a separate thin server on any of your servers that will handle websockets traffic.
Create a websockets.ru file in the root directory of your project. Use this file to configure the application handling websockets traffic.
![Page 19: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/19.jpg)
Architecture
![Page 20: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/20.jpg)
Supported Databases
PostgreSQL
MongoDB
Redis
https://shellycloud.com/documentation/supported_databases
![Page 21: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/21.jpg)
Shelly Console
You can use the shelly gem to run rails console or IRB for rack applications.
Console is ran on random application server with user privileges.
To run console, use shelly console
![Page 22: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/22.jpg)
Price comparison / Small app
3 thin workers, 1 delayed_job, 1GB database
Heroku$107(workers) + $15 (shared database) = $122 ~ €100
EngineYard$90 (small instance, 1 CPU, 1.7GB of RAM) ~ €73(no backups included)
Shelly Cloud€40(1 large instance, 2 CPUs, 2GB of RAM) + €0.60 (1 GB DB storage) = €40.6
![Page 23: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/23.jpg)
Price comparison / Medium app
10 workers, 3 delayed_job, 10GB database (dedicated)
Heroku$431 (workers) + $250 dedicated database = $681 ~ €558
Shelly Cloud€160 (4 large instances for workers, 2 GB RAM, 2 CPUs) + €40 (1 large instance dedicated db) + €6 = €206In total 10 GB of RAM, 10 virtual CPUs
EngineYard (Similar in case of RAM to shelly setup)$444 (2 medium inst 3.75GB of RAM (each), 2 CPUs, 1 small 1 CPU, 1.7GB of RAM),$24 (storage and bandwidth) = $468 ~ €384
![Page 24: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/24.jpg)
Let's do it in practice
LIVE deployment on Shelly Cloud
![Page 25: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/25.jpg)
Questions?
![Page 26: Painless ruby deployment on shelly cloud](https://reader034.vdocuments.site/reader034/viewer/2022051014/54bd16904a7959ff308b4618/html5/thumbnails/26.jpg)
Thank You
Giedrius RimkusSoftware Engineer
@giedriusr