How We Created a Multi-site Setup for a Vehicle Marketplace: Part 2
Tags: webdev, ruby, webperf, showdev
Published: 2019-05-03 08:43:37

---
title: How We Created a Multi-site Setup for a Vehicle Marketplace: Part 2
published: true
description: Codica team created a marketplace platform including 89 independent websites. How do we easily localize, configure, test, deploy, monitor them all? Check our article.
tags: webdev, ruby, webperf, showdev
cover_image: https://thepracticaldev.s3.amazonaws.com/i/bccixc9o9kt0uc2za519.jpg
---

*This article was originally published on [Codica Blog](https://www.codica.com/blog/multisite-vehicle-marketplace/).*

Today, we want to provide you with the second part of the article dedicated to creating a multi-site setup for a [multi-vendor vehicle Marketplace](https://www.codica.com/case-studies/multi-vendor-vehicle-marketplace/). Here we cover such challenges as **testing** and **deployment**. 

If you missed the first part, here is the [link](https://dev.to/codicacom/how-we-created-a-multi-site-setup-for-a-vehicle-marketplace-part-1-224b) for your convenience.

Let's get started and see what difficulties we faced.

## Testing

**Goal: Provide high-quality and timely testing of 89 websites**

Taking into account the fact that the websites’ number was steadily increasing, we understood that the only effective option is automated testing. It is much more time-efficient than manual testing and is easy-to-maintain because we have a single code base.

The first step towards automated testing was creating test cases, as we had no documentation for the website maintenance.

After some time we realized that test cases couldn’t cover all the project needs, and then we decided to take advantage of the following tools and practices.

### Repository configured CI

Initially, we had a goal to find a way to track the created tests and their execution. To achieve it, we have appealed to [Continuous Integration](https://docs.gitlab.com/ee/ci/) configured to a GitLab repo that tracks created tests. Using Continuous Integration may become extremely beneficial in case automation is essential in your workflow.

Consequently, it shows us whether a code review was executed positively or negatively that gives us an opportunity to avoid time-consuming tasks and spend much less time on repeated actions.

### Ruby Gems

[RSpec](https://github.com/rspec/rspec) refers to Behaviour Driven Development for Ruby. It gives an opportunity to track the customer’s behaviour on the website. It is of utmost importance to check what is working and what’s not. Our development does testing many languages and currencies that gives an opportunity to track the marketplace working capacity and check the setup performance.

[Capybara](https://github.com/teamcapybara/capybara) is a test framework for web applications. It clearly cooperates with RSpec as its add-on. With the help of this tool, we do integrated tests that stimulate how a real user would interact with an app. We can describe the authorization scenario in several lines, and then the gem provides different handy methods for tests debugging.

Here you can see how Capybara works with RSpec:

```javascript
describe "the sign-in process", type: :feature do
  before: each do
    User.make(email: 'user@example.com', password: 'password')
  end

  it "signs me in" do
    visit '/sessions/new'
    within("#session") do
      fill_in 'Email', with: 'user@example.com'
      fill_in 'Password', with: 'password'
    end
    click_button 'Sign in'
    expect(page).to have_content 'Success'
  end
End
```

Using RSpec and Capybara, we can run the system of **120 automated tests per 5 minutes**. 

## Deployment

**Challenge: Time-efficient deployment of the multi-site setup**

The best time-efficient solution is to create automated deployment scripts. Though the number of sites was increasing, we wanted to advance the deployment process. Let’s check how we achieved this goal. 

**Step 1. 16 websites: Capistrano**

Firstly, we have used [Capistrano gem](https://github.com/capistrano/capistrano) - a framework for building automated deployment scripts. After a while, the platform was growing and reached the number of 13-16 websites. Subsequently, it became pretty time-consuming to deploy more sites at one go and we decided to adopt **Mina**.

**Step 2. 40 websites: Mina**

By the time the websites’ number reached 40, each site deployment took 2-3 min that was too much. For your guidance, the whole platform deployment took 2 hours. It pushed us to move to [Mina](https://github.com/mina-deploy/mina) - a deployer and server automation tool.

With the help of this tool, we spent only 40-90 seconds per each site for the deployment. In a meanwhile, the sites quantity grew to 80+. That’s why we decided to parallelize the deployment into several streams to make it time-efficient.

**Step 3. 80+ websites: Mina-multideploy**

After a while, we realized that we need a parallel deployment tool due to the fact the number of websites was constantly growing. Thus, we built [Mina-multideploy](https://github.com/codica2/mina-multideploy) for parallel deployment. This tool runs [Mina](https://github.com/mina-deploy/mina) on many servers. 

Now, deployment is performed in several streams with the help of [Parallel gem](https://github.com/grosser/parallel). It gives us an opportunity to reach a huge amount of 89 websites simultaneously. Consequently, the deployment of the whole platform takes approximately 10 minutes.

How Mina-multideploy works:

![](https://thepracticaldev.s3.amazonaws.com/i/eoo1pifx6dnomez7oas7.gif)

Here you can see the deployment performance (average time) that was reached at each step. An improvement 

| Tools | Average deployment time |
| --- | --- |
| Capistrano Gem | 120-180 seconds / site |
| Mina | 40-90 seconds / site |
| Mina-multideploy | 8-12 seconds / site (10-15 min / platform) |

## Conclusion 

Here we presented you the second part of the article covering such challenges of [marketplace development](https://www.codica.com/services/online-marketplace-development/) like **testing** and **deployment**. The third (final) part is coming soon and there we will tell you about **adding new websites** and **monitoring** challenges.

Stay tuned and read the full article version here: [How We Created a Multi-site Setup for a Vehicle Marketplace](https://www.codica.com/blog/multisite-vehicle-marketplace/).