Netgate SG-1000 microFirewall

Author Topic: Switch or bridge for better performance?  (Read 435 times)

0 Members and 1 Guest are viewing this topic.

Offline dwasifar

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Switch or bridge for better performance?
« on: February 02, 2018, 01:42:15 pm »
I'm running 2.4 on a Watchguard XTM 5.  Currently I'm only using two of the XTM's six gigabit ports, one each for LAN and WAN.  The WAN goes to a Comcast gateway with 150Mbps/20Mbps service.  The LAN port goes to an unmanaged gigabit switch, to which the rest of the LAN devices connect. 

Would there be any noticeable performance advantage to bridging the XTM's remaining ports into a 5-port LAN, and moving the most internet-active connections to those ports?  Or would it be irrelevant because the WAN speed is the bottleneck?

Offline johnpoz

  • Hero Member
  • *****
  • Posts: 15189
  • Karma: +1414/-206
  • Not a pfSense employee, they cannot fire me...
    • View Profile
Re: Switch or bridge for better performance?
« Reply #1 on: February 02, 2018, 02:22:06 pm »
Its pointless and what is would do is slow down connections between those devices..
- An intelligent man is sometimes forced to be drunk to spend time with his fools.
- Please don't PM me for personal help
- if you want to say thanks applaud or https://www.freebsdfoundation.org/donate/
1x SG-2440 2.4.2-RELEASE-p1 (work)
1x SG-4860 2.4.2-RELEASE-p1 (home)

Offline dwasifar

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Switch or bridge for better performance?
« Reply #2 on: February 02, 2018, 05:24:28 pm »
Its pointless and what is would do is slow down connections between those devices..

Kind of what I expected.  Thanks.

Offline silentcreek

  • Newbie
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Switch or bridge for better performance?
« Reply #3 on: February 06, 2018, 08:55:58 am »
Short answer: The switch is better.

Long answer: It depends :P I actually tested the bridged performance of my Intel i211 NICs and it was much better than I expected. With pfSense I could push around 870 MBit/s over the bridge, while the same devices would achieve 960MBit/s when connected to a switch. So, a switch is preferable in general. But let's say you ran out of ports on your switch and want to connect just one or two more devices without buying a new or larger switch, then you could use the spare ports on your pfSense box and bridge them - given that the slightly decreased throughput doesn't hurt you.
Btw. I did the same experiment with Linux on the same hardware. On Linux, the bridge performed just as good as the switch. The difference in maximum throughput between the bridge and the switch was just 1-2MBit/s which I consider within the range of measurement uncertainty. So, I guess it does depend on your NICs and how the drivers are implemented or optimized.

Offline stephenw10

  • Administrator
  • Hero Member
  • *****
  • Posts: 12007
  • Karma: +474/-15
    • View Profile
Re: Switch or bridge for better performance?
« Reply #4 on: February 06, 2018, 09:01:57 am »
I would expect the bridge to be able to pass at line rate given sufficient processing power. There will be significant latency compared to a switch though.

Even if you can bridge at line rate that will be using CPU cycles that could be doing something more useful.

The only real reason to bridge interfaces is to filter between network segments in the same subnet.

That said I have bridged NICs before when I had spare ports (and CPU cycles) just to give additional access. Real switch ports are pretty much always better.

Steve

Offline johnpoz

  • Hero Member
  • *****
  • Posts: 15189
  • Karma: +1414/-206
  • Not a pfSense employee, they cannot fire me...
    • View Profile
Re: Switch or bridge for better performance?
« Reply #5 on: February 06, 2018, 03:34:27 pm »
Stephenw10 brings up a great point about the latency.. So while line speed might be very close.. What was the added latency?

Ok in a pinch oh I need a port and and I need it on this L2 and all my switch ports are full - ok.. sure.. But its not the correct use of said nic.. If you need switch port, use a switch.
- An intelligent man is sometimes forced to be drunk to spend time with his fools.
- Please don't PM me for personal help
- if you want to say thanks applaud or https://www.freebsdfoundation.org/donate/
1x SG-2440 2.4.2-RELEASE-p1 (work)
1x SG-4860 2.4.2-RELEASE-p1 (home)

Offline silentcreek

  • Newbie
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Switch or bridge for better performance?
« Reply #6 on: February 07, 2018, 03:22:18 am »
I didn't test latency thoroughly, but from what I could see, I didn't see any change that couldn't easily have been measurement uncertainty. But I recall an interesting old paper on the performance of a Linux based bridge compared to a commercial switch that also concluded that the bridge performs quite good in terms of both latency and throughput unless the CPU load on the system is high. They measured latency differences in microseconds, while I only have looked at milliseconds. In general, they found that only for small frame sizes there was a slightly higher latency while for larger frame sizes it was quite the same. It's this paper: http://facweb.cti.depaul.edu/jyu/Publications/Yu-Linux-TSM2004.pdf

Now, this relates to Linux and that's different from BSD, of course. But I'd be suprised if FreeBSD would perform so much worse than Linux in this regard.

That being said, I also ran this setup only for a couple of days as a temporary solution (which I don't need anymore), so I can't speak from long-term or profound experience.

Offline johnkeates

  • Hero Member
  • *****
  • Posts: 842
  • Karma: +60/-1
    • View Profile
Re: Switch or bridge for better performance?
« Reply #7 on: February 07, 2018, 02:38:35 pm »
Any 'software' bridge will be slower than an ASIC switch bridge. This is because doing it in software requires a lot of CPU cycles to get a packet from one interface to another. An ASIC just ends up using a LUT and in-hardware direct packet transfers. Where an ASIC might use 1 or 2 cycles to forward a packet from one interface to another, a software bridge on a CPU might need 2000 cycles. Initially, this is compensated a bit by the CPU running at much faster speeds, but it scales very badly. One interface to one other interface might work, but as soon as you add one or two more, or go to higher speeds it totally fails.

Offline SammyWoo

  • Jr. Member
  • **
  • Posts: 43
  • Karma: +0/-0
    • View Profile
Re: Switch or bridge for better performance?
« Reply #8 on: February 09, 2018, 07:51:39 pm »
The last thing u said, WAN is the bottle neck.

Extra LAN ports on a firewall is really intended if you have multiple LAN segments (subnets) and the FW box can be configured as a router to route those subnets.

Plus ask yourself, do you want to ship gigabits IntraLAN traffic through the FW, with its limited resources? or give it to a dedicated box like a switch?