Instant messaging app messages immediate update

I don’t understand, how instant messaging apps immediately load new messages in the chatbox when a friend is sending one? Are they sending every second request to a server, to get messages list or it’s more complicated schema here? How I’m supposed to do that, what’re the best practices?