A striking feature of our universe is its near criticality. The cosmological constant and weak hierarchy problems, as well as the metastability of the electroweak vacuum, can all be understood as problems of criticality. This suggests a statistical physics approach, based on the landscape of string theory. In this paper we present a dynamical selection mechanism for hospitable vacua based on search optimization. Instead of focusing on late-time, stationary probability distributions for the different vacua, we are interested in the approach to equilibrium. This is particularly relevant if cosmological evolution on the multiverse has occurred for a finite time much shorter than the exponentially-long mixing time for the landscape. We argue this imposes a strong selection pressure among hospitable vacua, favoring those that lie in regions where the search algorithm is efficient. Specifically, we show that the mean first passage time is minimized for hospitable vacua lying at the bottom of funnel-like regions, akin to the smooth folding funnels of naturally-occurring proteins and the convex loss functions of well-trained deep neural networks. The optimality criterion is time-reparametrization invariant and defined by two competing requirements: search efficiency, which requires minimizing the mean first passage time, and sweeping exploration, which requires that random walks are recurrent. Optimal landscape regions reach a compromise by lying at the critical boundary between recurrence and transience, thereby achieving dynamical criticality. Remarkably, this implies that the optimal lifetime of vacua coincides with the de Sitter Page time, τcrit ∼ MPl2/H3. Our mechanism makes concrete phenomenological predictions: 1. The expected lifetime of our universe is 10130 years, which is ≳ 2σ from the Standard Model metastability estimate; 2. The supersymmetry breaking scale should be high, ≳ 1010 GeV. The present framework suggests a correspondence between the near-criticality of our universe and non-equilibrium critical phenomena on the landscape.