I have a single ethernet switch. Should I use spanning tree?
If there is a redundant link, definitely need to enable STP. In a single switch, how is it possible to have a redundant link? Any other possible scenarios?
Network Engineering Stack Exchange is a question and answer site for network engineers. It only takes a minute to sign up.Sign up to join this community
To add to Zac67's and JFL's answers:
In case you decide to enable spanning-tree on the single switch, don't forget to configure the client's and server's switchports as Edge Ports (Cisco speak;
spanning-tree portfast [trunk],
spanning-tree portfast edge [trunk] or
spanning-tree port type egde [trunk] , depending on platform and software generation).
This avoids having [edited after comment] STP's Listening and Learning phases on the switchport (15 sec each) or RSTP's Learning phase (sending 16 "proposals" every 2 seconds and waiting/timeouting for an "agreement"), after line protocol has come 'up'.
DHCP client software (and other things, too) on the end systems is usually not very happy with the ~30 seconds of silence after - from their point of view - the NIC's line protocol has come up. Usually, clients and servers and the software they run are not aware that it the takes the (portfast-less) switchport 30 seconds to go into forwarding mode.
In short: A sanely done STP configuration - even on a single switch - is a good safety net for your network. A badly executed STP configuration however (classic examples: Bridge priorities not set, "wild" topology with various/random link speeds, forgot portfast) can be worse than none.
To answer the second part of your question:
In a single switch, how is it possible to have a redundant link?
Yes, that's where "Link Aggregation", "Ethernet Trunking" (not be confused with VLAN trunking), "EtherChannel" or "PortChannel" (depending on how the vendor calls it) come into play.
It's the thing two devices with multiple Ethernet ports can do to consider a set of ports/links (usually 2-8) as one single logical link, in terms of addressing, presentation towards the upper layers in the network stack, but also in spanning-tree logic (in extenso: The virtual port aggregate becomes a single port, and VLAN, Spanning-Tree, and IP configuration elements are applied to the aggregate, not the member ports forming the aggregate). The protocol used to negotiate link aggregation is called LACP (Link Aggregation Control Protocol), the whole thing also known as IEEE 802.3ad.
LACP can provide some redundancy (even more so if the switch is a multichassis setup ), but also performance scaling, especially for inter-switch links, but also for attaching powerful servers to the network. When used as inter switch link, it can make sure that all links are being utilized, while none is being blocked by STP.
Keeping STP running as a safety net is even more recommended when LACP links are present.
 Cisco Catalyst StackWise, Cisco VSS and Cisco Nexus VPC, Juniper MC-MLAG, Arista MLAG, HP-Aruba Distributed Trunking etc.. most Vendors have something like this in their portfolio.
However, some of these may not fulfill the "single switch" premise you gave in your question. Not all of them tie multiple switches into "one single switch" in terms of configuration logic. StackWise does certainly, VSS does somewhat, VPC doesn't. I can't tell for the others.
As explained by Zac67 answer STP is normally only useful when connecting several switches together.
However there's other related features than can be useful on a standalone switch.
BPDU Guard will protect your network in case 2 links are connected to the same device. The most common case in my experience is with IP phones.
BPDU Guard will disable the port if the port receive a BPDU on a port on which it is not expected.
Of course to use this feature, (x)STP must be enabled.
So yes you may benefit from activating STP to use BPDU Guard, if there's a risk of loop - especially if you use 2 ports IP phones.
Also you should enable spanning-tree portfast or equivalent, see Marc 'netztier' Luethi answer for more details
STP protects your network in case two switch ports are connected together, so you should use it generally.
With a single switch, you can have redundant links to an appropriately configured host. However, you must not connect multiple links between switches/bridges unless you're using STP, LAG or SPB.