I'm an inexperienced PHP programmer and I am making a website using Codeigniter which runs on a server of a webhost. This website should, among other functionality, contain multiple chatrooms where medium-sized groups (+/- 25 people) could have real-time chat sessions. The number of chatrooms depends on the popularity of the site, so the chat functionality should be scalable and I want to be prepared to host hundreds or thousands of chatrooms.
I've found that one way to do this, is using short-polling with ajax, i.e. saving every message in the database and polling the database every second. I thought this approach would not scale well (as it seems very intensive for the database), so I thought it would be better to use a long-polling approach, e.g. websockets with node.js.
I'm not experienced with using sockets and as far as I've seen, node.js requires you to use your own server (e.g. localhost). Ideally, I want to integrate the functionality of node.js in my website so that every upcoming message is pushed to all the other chat-users, and that the messages are once in a while (e.g. every 10 minutes) sent to the database, so that chat history could later be reviewed.
This doesn't seem possible as node.js needs to independently run on your own server. What could I do to make my chat work with websockets, while using the server of the webhost? Is this possible? Should I use a different webserver instead of a webhost, or should I stick to short polling? Many thanks in advance.