WSL icon indicating copy to clipboard operation
WSL copied to clipboard

WSL access to local sites is too slow.

Open shirkerohit opened this issue 5 years ago • 4 comments

Environment

Windows build : image

Windows build number : 10.0.19042.685 Your Distribution version: VERSION="20.04.1 LTS (Focal Fossa)" Whether the issue is on WSL 2 and/or WSL 1: BOTH

I have setup local development environment for PHP web development (Laravel) Setup : apache2 + Mysql + php7.3/7.4

Steps to reproduce

  • Install apache
  • Install PHP
  • Setup vhost
  • Create symlink to project folder into /var/www/
`<VirtualHost test.test:80>
        ServerName test.test
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/test_app
         <Directory /var/www/test_app/>
           Options FollowSymLinks
           AllowOverride All
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>`
  • Setup hosts file : add domain entry
127.0.0.1  test.test
::1             test.test

Note : I have entry in my windows hosts file the same entry.

Expected behavior

Any requests to any domain should not take more than 1-2 seconds.

Actual behavior

All request takes almost 8-9 seconds or more.

More : https://twitter.com/rohit_p_shirke/status/1340745874444574725?s=20

shirkerohit avatar Dec 21 '20 17:12 shirkerohit

It turn out to be something related to file system thing. I am still wondering about how come I did not faced It earlier with WLS1 ( I am aware of WSL2 having filesystem issue as known bug and it's been worked on) and only after I reset and re-installed, all of sudden it hit me on face. ( I am 100% sure I only installed wsl1 😅)

The problem (At least, In my case)

My projects were located under windows directory and I had configured them for apache as direct link (Specify absolute path eg. /mnt/c/projects) or I was using sym links to windows directories to apache /var/www directory.

**Solution : **

I just moved all my projects to WSL directory and now everything is working like breeze! (Thought it wasted my couple of important hours😶)

I just hope WSL3 will address all those issues!

shirkerohit avatar Dec 22 '20 09:12 shirkerohit

i face same issue sir, when i run codeigniter 4 project in mnt, it load as hell slow (it takes more than 10s). Then i move all of it to my wsl local, and it is working fast as expected.

Cryxto avatar May 20 '22 15:05 Cryxto

WSL 2 is relatively faster in terms of performance tweaks but hugely lags in case of filesystem performance!

Another open thread https://github.com/microsoft/WSL/issues/4197

shirkerohit avatar May 26 '22 07:05 shirkerohit

Thanks for sharing the article, I had your same problem and your article convinced me that I should install the PHP program directly in wsl2 instead of soft connecting to win10 to do it. It is indeed quite fast to install and run a program or website directly in wsl2! I just experienced it after doing it! Thanks!

https://github.com/microsoft/WSL/issues/11576#

stuffren avatar May 12 '24 11:05 stuffren