Accessing the solr folder folder from multiple server instances - ruby-on-rails

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.

Related

Ruby on Rails as an appliance

Is there a way to package my rails application as an appliance on a virtual machine that has a database already setup in postgres? When such appliance is run, it should simply run the rails application and be ready for use.
I don't see any obstacles for that, you just have to configure database connection URL to Postgres upfront through env var at VM, so Rails (ActiveRecord) will pick up it during launch.
But if you require packing consider to look at containers, particularly Docker.

Sunspot / Solr on production server

Just moved from Sphinx to Solr / Sunspot Gem for Rails,
was using gem 'sunspot_solr' with RAILS_ENV=production rake sunspot:solr:start to run Solr on production server.
After whole day of indexing, in the morning all indexes disappear was lost, without error or any log about what happened. Same happened next day.
After some research i noticed this:
Sunspot comes with a prepackaged instance of Solr, which makes it easy to get started in development mode.
This will store the index data in your operating system’s temporary directory
I suspect that "rake sunspot:solr:start" is used for development only and that data is not persistent. But there a lots of tutorials that use this way to start Solr on production server without Tomcat.
What is the correct way of setting up Solr on production, do i have to use Tomcat, or "rake sunspot:solr:start" is a proper way of starting Solr.
Im confused , any help is appreciated.
There's a whole page on the community wiki dedicated to taking Solr to production with examples of init scripts etc. if your distribution doesn't provide them (or running under Windows).
The easiest way is to use the bin/install_solr_service.sh script:
Solr includes a service installation script (bin/install_solr_service.sh) to help you install Solr as a service on Linux. Currently, the script only supports CentOS, Debian, Red Hat, SUSE and Ubuntu Linux distributions. Before running the script, you need to determine a few parameters about your setup. Specifically, you need to decide where to install Solr and which system user should be the owner of the Solr files and process.
This uses the supported, bundled version of Jetty with Solr and sets it up properly as a service on your server.
Under Windows the current recommended way is to use NSSM.

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.

Configuring Neo4j on Rails to Deploy with Warbler

How do you configure a Neo4j on Rails app to deploy with Warbler? As it stands, every time I deploy my app, the previous production instance of neo4j gets destroyed, because neo4j is embedded. I was hoping that there would be some kind of configuration for production, either through Warbler or through neo4j, so that once a neo4j instance is created on the server it is not replaced with the next deployment.
I guess you could place the neo4j database somewhere persistent outside your volatile codebase and then open Neo4j against e.g. /var/database ? In case there are existing files, Neo4j will not replace them.

cloudfoundry worker be same application instance as server

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.

Resources