cloudfoundry worker be same application instance as server - ruby-on-rails

Is it possible for the resque worker and the resque server application to be the same application instance in cloudfoundry. My server application saves a file, the worker instance is a standalone ruby class that has to read the file from the server instance.
Both are ruby rails applications. I have tried saving it in a postgres bytea but activerecord fails to save with memory error. It could be my meagre dev machine.
I have been told to use Mongodb but my app requires postgres...and box.net is not free. Ideally I need a free way of sharing files or two have them run on the same application instance or three find some other low memory way of having the worker ruby standalone class read the file stored from the rails server upload

I would recommend using Amazon S3 for storing files, it's cheap and I think you pretty much get it for free during the first year! Take a look at the Paperclip gem for integration in to a Rails project.

Related

Accessing the solr folder folder from multiple server instances

AWS has just announced general availability of its EFS (Elastic File System). It allows you to create a network drive that can be shared by multiple AWS instances.
I have a Rails application, using sunspot-solr gem. A solr folder is created to store the solr index file and other related data.
The MySQL data is on its own RDS instance. I want to deploy two servers, both running the same Rails application, but have them both point to the same solr folder on the shared EFS share.
Assuming that both servers running the Rails app, are using the same solr gem version, will my scenario work, or will each server need its own solr folder?
I'm pretty sure the version of Solr packed with the development version of Sunspot is a separate Solr server that Rails communicates with. So in production, you are responsible for providing a Solr server for these purposes, be it on one of your EC2 instances or on its own separate EC2 instance.
A little more info... Rails posts data for Solr to consume via Sunspot, but the Solr server handles those details, not your Ruby app. Therefore, sharing the Solr data files with Rails won't provide you with any advantage.
When I was getting started, I hooked my Heroku-hosted Rails app up to Websolr if you think that $20+ per month would be worth it. Otherwise, look up tips for installing Solr on EC2.

How to create a multi-app Ruby on Rails shared environment

I am looking to create a shared hosting environment allowing for multiple RoR apps to be running well isolated from one another (and the underlying os), running different versions of RoR as required.
My question is can this be done without having to resort to OpenVZ/Virtualisation?
If so, would the following approach be suitable - what would be required to make apps well isolated from each other and the OS?
NGinx, single instance for load balancing
Unicorn, multiple instances started by NGinx to handle requests (capable of running different versions of RoR
(Rbenv or RVM) and Bundler allow to isolate gems of different Rails applications.
So there will be no troubles with that.
Each rails app will have its own instance of Unicorn(puma, thin, whatever).
Nginx will have separate domain name based virtual host for each rails app, and will forward requests to upstream(Unicorn/Puma).
Each rails app should have separate database at db server too.
So I don't see any problems with isolating multiple rails apps.
For additional isolation you can use Docker, so each app will be running in separate container.

deploy rails choices

After I finished reading Agile Web Development with Rails, I Have developed my own website.
Now I am trying to deploy my project on linux system I rent, but I know nothing about how to deploy rails.Which server should I user? How to connect to mysql database?
As a java developer, I know I can use tomcat as my server which can convert http request to my own object and use jdbc to connect to my mysql database.
Now I want to know what is the main stream environment rails deployed?
I have heard of Lighttpd and FCGI. Can I use them in the product environment?
thanks
Is your linux system a full VPS (you have complete control?) If not, check your hosting company to see what options are available to you. If so, check to see if they have guides for setting up Rails. A lot (Slicehost, Linode, etc.) do.
Failing that... I would recommend either Apache (or Nginx) with Passenger.
https://www.phusionpassenger.com/
It's pretty straight forward.
As for actually deploying, look into Capistrano (or Vlad). These are a little bit more complicated, but they make life so much easier in the long run.

Can a Heroku app interface with Amazon EC2 instances

I am toying around with building a rails app in the near future and using Heroku to host it, but the app will need to interact with EC2 instances through SSH (unless I can find a better way). I probably could build a pseudo API...but direct console access would be easier. I am going to need the following:
1) Run commands on the EC2 console
2) Read the results
3) dynamically start and stop ec2 instances (a little unrelated but I am curious if heroku can do this)
I know heroku hosts their infrastructure on EC2, so latency would be grean and it would probably be more straight forward to just host my own rails server on an EC2 instance, but I really like the automation and tools available within Heroku.
EC2 specific: http://rubygems.org/gems/amazon-ec2
Console Commands/Results: http://rubygems.org/gems/net-ssh
Both these Gems should address my issue. Thanks Zabba for the ec2 gem. I am a little new to rails, and should have started looking there. I love how easy it is to install new functionality into the language.

Is there a linode version of EC2 on Rails?

We really like the idea of hosting with Amazon EC2 and the excellent EC2 on Rails, but our cashflow isn't enough to justify a move to EC2. So we've decided to host with linode. Now we're trying to put together the best Rails server build.
For those that don't know, EC2 on Rails is an opinionated Ubuntu Linux Server image for Amazon's EC2 hosting service. Out of the box, it runs a standard Ruby on Rails application with little to no customization.
So, is there something like EC2 on Rails for linode?
We'd need at least the following:
Ruby 1.8.7
Ruby on Rails 2.3.8
MySQL 5
memcached
Automatically runs hourly, daily, weekly and monthly scripts if they exist in Rails application’s script directory
Local Postfix SMTP mail server
SSL support
Passenger + Ngnix or Mongrel + Apache
32 bit image Ubuntu
With a railsy setup, meaning fast and simple. So, anyone run across anything like EC2 on Rails, but for linode?
I have been using linode for my personal use for a while and I think no matter what, you are probably going to have to get your hands dirty. I kind of like it for exactly that reason, but that is just my taste. They do have stack scripts with some predefined setups. The closest I can find to what you are looking for is a ruby/apache/mysql script that is fairly customizable.
From the script:
Installs a fully functioning, ready to
go stack that's optimized specifically
for your Linode's resources. By
default, it creates a VirtualHost
using the reverse DNS of your Linode's
primary IP.
This installs a stack based on Ruby,
Apache, and MySQL. This also gives you
the options to install gems so that
you can be up and running Ruby on
Rails in no time.
Optionally creates a MySQL database
and user, and assigns that user grants
to the database.
You may use this as an example for
creating more VirtualHosts. Set up
VirtualHosts, install your sites,
point your domains to your Linode, and
you're set!
This script downloads and compiles the
source from Ruby's ftp. Along with
Ruby, the latest version of ruby gems
is installed and you have a choice of
initial gems to install. Rails and
passenger can be used to have a ready
to go Rails server. Once this script
has finished be sure to run
'passenger-install-apache2-module' to
complete the passenger install.
Note that this script may take 1.5 - 2
hrs depending on the gems that are
specified.
All details of this stack script are
logged to /root/log.txt and the stack
script is finish when the line
"StackScript Finished!" is written to
the log file.
You might have good luck talking to their support though, they might have some more secret sauce that I haven't found yet.
Nothing in that setup sounds EC2-specific beyond the name. It appears it is just convenient to use with EC2, because they let you grab a disk image from another account.
You are welcome to create your own StackScript to do this and contribute it to the community. Once a StackScript is written, it can be marked public and used by others. EC2 on Rails has a public GitHub repository from which you can get started, and honestly, I'd love to see things like this ported to the StackScript system.

Resources