Thursday, August 20, 2020

Improve Parallels performance for Windows OS running on Mac

If you are using Parallels for mac to run Windows OS for development purpose then these tips can help you to slightly increase the performance.

I am a full stack developer which means I have to work on different tools and IDEs day-in and day-out. While those tools and IDEs are there to help us develop quality products, they sometimes go crazy and decrease our productivity by taking more resources than they are actually supposed to take. Similar kind of thing was happening with me from quite some time when I was running Windows OS on the Parallels for Mac.

I had to run multiple instances of Visual Studio (mostly 3) along with MongoDB, SQL Server, Git bash and Postman. After running all this when I used to start my services to debug, chrome instances for swagger UI and command windows used to pop open further decreasing the Parallels performance running with 4 GB ram and 2 CPUs. Running local Kafka for EDA was cherry on the cake.

So we came up with a solution that we will run MongoDB docker container instance on Mac to run a local instance of MongoDB. Similarly, we decided to run a local instance of Confluent Kafka on Mac (will provide the setup details in my upcoming blog).

Though this proved to be really helpful still there was a lot of lag while debugging the services on Visual Studio. With Mongo and Kafka out of Parallels, I was left with SQL Server, Git bash, Postman and Chrome. Then I thought let's try and get rid of the last two as well. I didn't need the Swagger UI to remain open in Chrome because I was using Postman to hit the services. Also, I questioned myself if I can run Mongo on Mac and hit it from the services running on Parallels then why can't I hit the services from Postman running on my Mac?

And oh yes I forgot to mention it earlier I was working on .net core services and following the micro-service architecture (hence had to run multiple services). 

I was able to answer my questions followed some simple steps and believe me, it has made my life much simpler. So here's what I did:

1. Stopped the swagger UI to open every time I started my web service

Open the solution in Visual Studio. Find and open the file launchSettings.json under the Properties folder of your startup project. Locate the "launchBrowser" property in that JSON file and make that false.

2. Changed the web-service application URL from localhost to the Parallels IP

This is needed for the next step to work perfectly.

Find the Parallels IP by running ipconfig command in the command prompt. In my case, it was 10.211.55.3. Again open launchSettings.json, locate "applicationUrl" property and replace localhost with the IP. It will look something like this:
"applicationUrl": "http://10.211.55.3:50352"

3. Enabled port forwarding for Parallels

It is needed to communicate to the services running inside Parallels from Mac. To achieve this open Parallels preferences by using a combination of Command Key (⌘) and comma (,) while on Parallels desktop or by clicking on || symbol on Mac's menu bar and by selecting Preferences...

Parallels menu

It will look something like this...


Unlock this if it is locked by clicking on the small lock at the bottom left of the screen and authenticate.

Go to the Network tab (1) and select Shared network (2). Next, click on Plus sign (➕) under Port forwarding rules (3). Add the port on which web-service is running along with the Parallels IP which we noted in the previous step. The source port is Mac's port and destination port is Parallels port.


Parallels Desktop Port Forwarding Configuration

Hit OK and close the Parallels Desktop preferences.

You can add multiple port forwarding rules if you have to connect to multiple services from Mac. In my case, I had to connect to just one service which internally communicated with other microservices through Kafka.

4. Run Postman on Mac

This was it. I was all set-up and ready to test.

I ran the web-service in Parallels using Visual Studio. Open Postman on Mac and hit the web-service using http://localhost:<service port>/<endpoint> or http://<Parallels IP>:<service port>/<endpoint>


I have tried to put in as many details as possible. I hope this was helpful.

Cheers!!