Modern datacenter applications need to provide resiliency to mask failures. These applications widely use techniques like Replicated State Machines to provide fault tolerance. Replicated State Machines typically rely on consensus protocols to provide availability and consistency. These applications also require high throughput and low latency from the underlying consensus protocols. Furthermore, in an effort to further reduce latency experienced by clients, we are seeing the emergence of edge computing; storage and computational resources are placed in between the clients and servers in datacenters (typically closer to the client). This placement provides many benefits: lower-latency responses to clients, lower bandwidth demands on the backbone and increased privacy. Stateful applications running on the edge pose a problem of losing state when an edge node fails. This dissertation looks at fault tolerance for datacenters and edge computing. First, RingWorld looks at datacenter fault tolerance for highly available lock services. RingWorld adapts ring-based consensus protocols to leverage programmable switches and datacenter topology. This allows RingWorld to provide higher throughput and comparable latency to existing lock services. Second, to provide fault tolerance for edge computing, CESSNA provides a mechanism to recover from edge failures for strongly stateful applications that ensures correctness and good performance. To do this, CESSNA defines the consistency guarantee for correctness in the face of edge failures, and recovers from failures by adapting techniques like log-replay.