I will discuss a close parallel between Gaiotto and Witten's S-duality for supersymmetric boundary conditions in 4d N=4 SYM and the relative Langlands program, an enhancement of the Langlands program that was developed to provide a framework for the theory of integral representations of L-functions. A special and conjecturally self-dual class of boundary conditions is provided by quantizations of "small" or "multiplicity-free" hamiltonian spaces called hyperspherical varieties. I'll explain how a hyperspherical variety produces objects of interest in all the different settings of the Langlands program (local / global, geometric / arithmetic) and a collection of conjectures providing S-dual descriptions of these objects. The talk is based on forthcoming joint work with Yiannis Sakellaridis and Akshay Venkatesh.