How does Groupme or Instagram works?

How does groupme or instagram really works? I know in groupme when you want to send a message everybody receives it instantly. Do they have somebody in a company transfer all the data? How are all the old messages save? Do they have a cloud program? How does it work when there's an app that save data files?