Understanding human interactions in online communications is of paramount importance for our society. Alarming phenomena such as the spreading of fake news or the formation of echo-chambers can emerge in unhealthy communication environments and, ultimately, undermine the democratic discourse. In this context, unveiling the individual drivers that give rise to collective attention can help to conserve the health of our information ecosystems. Here, following a recently proposed analogy between natural and information ecosystems, we explore how competition for attention in online social networks and the strategies adopted by the users to maximize their visibility shape our communication dynamics. Specifically, by analyzing large-scale datasets from the micro-blogging platform Twitter and performing numerical modeling of the system dynamics, we are able to measure the amount of competition for attention experienced by users and how it changes when exogenous events captivate collective attention. The work relies on topic modeling to extract users’ interests and memes context from the data and a framework based on ecological niche theory to quantify the strength of negative (competitive) and positive (mutualistic) interactions for both users and memes. Interestingly, our findings show two different behaviors. While memes undergo a sharp increase in competition during exceptional events that can lead to their extinction, users perceive a decrease in effective competition due to a stronger effect of mutualistic interaction, explaining the focus of collective attention around specific topics. Finally, to confirm our results we reproduce the observed shifts with a data-driven model of species dynamics.