# LAN vs public syncing

**URL:** https://forum.syncthing.net/t/lan-vs-public-syncing/2271
**Category:** Support
**Created:** [March 28, 2015, 4:05am UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271 "2015-03-28T04:05:37Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![nem2k](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/n/d78d45/32.png) [@nem2k](https://forum.syncthing.net/u/nem2k)
#### Post date: [March 28, 2015, 4:05am UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/1 "2015-03-28T04:05:37Z")

</div>

I just migrated over to syncthing to see how it compares to btsync - liking it so far!

I’m wondering 2 things:

1. Is it possible to force a sync to happen over a local/internal network? If so, how do I check that this is the case? Right now, I have a folder uploading to my NAS, but the upload speed is around 10-15MB/s, which is very slow for my gigabit network

2. How does syncthing decide whether to use a local network, or to route publicly over the internet? My concern is my bandwidth given I have a monthly cap.

My desktop computer will always be at home syncing to my local NAS - so ideally I’d just transfer locally over my network to save on bandwidth. However, my laptop tends to travel with me. When I’m at home I’d like my laptop to sync over the local network, but when I’m at work I’d like it to still sync over the internet. Is it possible to achieve something like this?

My main concern is bandwidth usage, and want to achieve a setup where usage is minimized with little fuss

---

<div class="post-metadata">

### Author: ![wweich](https://forum.syncthing.net/user_avatar/forum.syncthing.net/wweich/32/1063_2.png) [@wweich](https://forum.syncthing.net/u/wweich)
#### Post date: [March 28, 2015, 8:26am UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/2 "2015-03-28T08:26:38Z")

</div>

If local discovery is enabled or you enter the IP:Port of the other Node in the device settings, instead of dynamic, then syncthing will only transfer locally. You can check that by expanding the device on the right side of the web interface. If it shows a local IP, than it is syncing locally.

I did set up the sync between my desktop and server with their local IP set in the device settings of each other, so they can only sync locally, and I have the same low speed as you have.

---

<div class="post-metadata">

### Author: ![nem2k](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/n/d78d45/32.png) [@nem2k](https://forum.syncthing.net/u/nem2k)
#### Post date: [March 28, 2015, 9:27am UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/3 "2015-03-28T09:27:47Z")

</div>

thanks, sounds easy

If I have both local and global discovery turned on on my laptop, will it favour global discovery when Im away from the lan, and switch to local discovery when Im at home automatically? (using dynamic instead of a fixed ip)

---

<div class="post-metadata">

### Author: ![wweich](https://forum.syncthing.net/user_avatar/forum.syncthing.net/wweich/32/1063_2.png) [@wweich](https://forum.syncthing.net/u/wweich)
#### Post date: [March 28, 2015, 9:44am UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/4 "2015-03-28T09:44:58Z")

</div>

Yes, it works that way with my Adnoird devices. When in home WiFi it uses local discovery and shows the local IP address, and when in foreign WiFi it connects through global discovery.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [March 28, 2015, 11:23am UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/5 "2015-03-28T11:23:52Z")

</div>

> [@nem2k](#):
>
> 10-15MB/s, which is very slow for my gigabit network

The network is most likely not the bottleneck. We do a lot of hashing, crypto and other shuffling that probably means you’re CPU limited to that rate.

---

<div class="post-metadata">

### Author: ![wweich](https://forum.syncthing.net/user_avatar/forum.syncthing.net/wweich/32/1063_2.png) [@wweich](https://forum.syncthing.net/u/wweich)
#### Post date: [March 28, 2015, 3:57pm UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/6 "2015-03-28T15:57:47Z")

</div>

I just ran a test with a 2.1GiB file (MP4). I closed both web interfaces\* and watched the folder listing in 10s intervals. The new file went from 13MB to 1.1Gib and from 1.1Gib to 2.1GiB in 10s (each) while the CPU usage on both devices was not very high. So it transfered at about the maximum of my Gbit LAN.

After that i did another test with a 10GiB file (MKV), which was only transfered at about 10 - 15 MiB/s while the CPU usage of syncthing was at 350% (all 4 cores at 80 - 90% each) on the sending side and at ~90% on the receiving side.

I ran each test twice with same results.

I also tested 2x1,3 GiB files (MKV) which caused a CPU usage of ~150% at sender and transfered at ~40MiB/s

My sending device is a Core i5 4590S (M2 SSD) and the receiving device is a Core i3 3220T (WD RED HDD, RAID1).

The transfer rate and CPU usage differs from the content and amount that is to be transfered. Why is that?

* * *

\*_It is known, that the transfer speed takes a hit, when having the web interface open, even though not CPU nor ram is really limiting._

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [March 28, 2015, 4:15pm UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/7 "2015-03-28T16:15:56Z")

</div>

this is my theory:

I feel that when transferring larger files we get hit throttled by garbage collector (because more data travels, we need to allocate more buffers for reading stuff into, and the garbage collector has to do more work to make sure we are still within sane memory limits hence it kicks in more often stopping everything else that is running).

Also, it’s possible that parts of the MKV you were sending were already at the destination (in some form, perhaps parts of it were the same as some other file), hence there was very little transfers as syncthing was just rebuilding the file from what it already had around.

---

<div class="post-metadata">

### Author: ![wweich](https://forum.syncthing.net/user_avatar/forum.syncthing.net/wweich/32/1063_2.png) [@wweich](https://forum.syncthing.net/u/wweich)
#### Post date: [March 28, 2015, 5:13pm UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/8 "2015-03-28T17:13:23Z")

</div>

The 2.1GiB MP4 file was already in another shared folder, so the test is more or less invalid. I repeated the test and saw that the complete file was blue (copied from original). I used another 1.8GiB MP4 which is wasn’t in any other shared folder, and the speed and CPU was comparable to the test with the 2 1.3GiB MKV files.

Additionally I tested a 4.4GiB MP4 file, which was transfered at about a little over 30MiB/s while syncthing used about 300-330% CPU on sending device.

The more is to be transfered, the slower and more CPU intensive it gets.

I did a few more tests with smaller files and the fastest transfer speed I could reliably measure was about 40MiB/s with a little less than 100% CPU usage.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [March 28, 2015, 5:21pm UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/9 "2015-03-28T17:21:44Z")

</div>

> [@wweich](#):
>
> The more is to be transfered, the slower and more CPU intensive it gets.

This is counterintuitive to me (the cost per block shouldn’t increase just because there are more blocks to transfer), so something that should be investigated…

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [March 28, 2015, 6:36pm UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/10 "2015-03-28T18:36:12Z")

</div>

> [@Disable data encryption](https://forum.syncthing.net/t/disable-data-encryption/416/43):
>
> Receiver: 100MB all files empty - no data 1GB: (pprof) top 81.35s of 81.74s total (99.52%) Dropped 17 nodes (cum \<= 0.41s) Showing top 10 nodes out of 24 (cum \>= 1.43s) flat flat% sum% cum cum% 50.56s 61.85% 61.85% 50.56s 61.85% crypto/aes.encryptBlockGo 26.09s 31.92% 93.77% 26.09s 31.92% crypto/cipher.(\*gcm).mul 2.50s 3.06% 96.83% 2.50s 3.06% crypto/cipher.getUint64 1.25s 1.53% 98.36% 1.25s 1.53% scanblock 0.45s 0.55% 98.91% …

Says otherwise, as for sending a 5GB file, we spend 14% of the time in heap scans, 10% in crypto, 30% in serializing. Where as with 1GB file we spend 50% in crypto, 4% in heap scans, 20% in serializing.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [March 29, 2015, 7:08am UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/11 "2015-03-29T07:08:39Z")

</div>

Just for fun, how does `GOGC=400 syncthing` gerform?

---

<div class="post-metadata">

### Author: ![wweich](https://forum.syncthing.net/user_avatar/forum.syncthing.net/wweich/32/1063_2.png) [@wweich](https://forum.syncthing.net/u/wweich)
#### Post date: [March 29, 2015, 4:17pm UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/12 "2015-03-29T16:17:15Z")

</div>

I repeated the Test with a 10GiB MKV file with GOGC=400. The speed was better with ~25MB/s and the CPU usage of sending syncthing was higher than before; mostly at 385 - 390%.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [March 29, 2015, 5:03pm UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/13 "2015-03-29T17:03:02Z")

</div>

Lots of various numbers in your post, but I guess that’s about twice what you saw with the default GC setting?

---

<div class="post-metadata">

### Author: ![wweich](https://forum.syncthing.net/user_avatar/forum.syncthing.net/wweich/32/1063_2.png) [@wweich](https://forum.syncthing.net/u/wweich)
#### Post date: [March 29, 2015, 5:36pm UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/14 "2015-03-29T17:36:43Z")

</div>

yes, almost. With a 10BiG MKV file I get: Default GC: ~15MiB/s, ~350% CPU GOGC=400: ~25MiB/s, ~385% CPU

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [March 29, 2015, 8:05pm UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/15 "2015-03-29T20:05:12Z")

</div>

We’ve merged a change to set the default to GOGC=100 (previously 25).

> <https://github.com/syncthing/syncthing/pull/1541>

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [May 12, 2017, 12:58pm UTC](https://forum.syncthing.net/t/lan-vs-public-syncing/2271/16 "2017-05-12T12:58:03Z")

</div>


