I
I
icegreenberry2010-12-16 16:51:53
MongoDB
icegreenberry, 2010-12-16 16:51:53

PHP XMPP 24/7 bot

Hello. There was a need to write a jabber bot that would work around the clock, while receiving and sending about 2000 messages per hour and working with the MongoDB database.
The bot will work on Linux, but since I do not have sufficient knowledge of C / C ++ (which is preferable for this task), I want to write it in PHP 5.3.
But what about this kind of tasks in PHP? Will such a script have low performance? Will it "eat" memory?
Thanks for the hints.

Answer the question

In order to leave comments, you need to log in

9 answer(s)
R
Riateche, 2010-12-16
@Riateche

At one time I tried to solve a similar problem. Nothing good came of it: the connection was constantly torn or hung up. In principle, there should be no problems with memory. If they are, you can restart the script at certain intervals, it's not scary.
I would suggest learning one of the higher level languages ​​(like Python or Ruby). Mastering Ruby at the initial level is a matter of one day, and such tasks are solved on it an order of magnitude easier.

S
shsmad, 2010-12-16
@shsmad

python+twisted?

V
VBart, 2010-12-16
@VBart

Spend a couple of days learning Python and write in it (you can use Twisted, as mentioned). It will be much better, both for you and for solving the problem.

C
Carzil, 2010-12-16
@Carzil

I once wrote in python'e + xmpppy:
wiki.linuxformat.ru/index.php/LXF121 :Python
xmpppy.sourceforge.net/

K
korotovsky, 2010-12-16
@korotovsky

Here http://steelbot.net you can find the Jabber bot, with plugins and other goodies. The best option I have ever seen.

S
slang, 2010-12-16
@slang

2000 per hour, this is an average of 1 message every 1.8 seconds, do you really think that this is a serious load? The PHP CLI daemon can easily cope, especially since there will be a frisky NoSQL storage.

V
Vladimir Chernyshev, 2010-12-17
@VolCh

The performance is quite enough for such loads, if the bot logic is simple, and not a neural network for passing the Turing test :)
In order not to write a lot from scratch, I advise you to look at phpdaemon

H
Horse, 2010-12-16
@Horse

2000 messages per hour is not a big load for stateless (and as I understand it, little depends on states). First of all, you need to optimize queries to the database. And about XMPP itself, you don’t have to worry, I’m sure that you don’t need low-level work with memory, threads, sockets. If there is a ready-made php library - use it and don't be afraid - it will even be better, because with ++ web applications they compile into native code and a small mistake will make your XMPP bot not ready for 24/7. And in php, errors do not affect the application itself (the web server will not stop). nginx (or whatever you have) will deal with the memory at the proper level. The main thing is not to apache).

O
OdaN, 2010-12-17
@OdaN

There are ready-made scripts for php: code.google.com/p/xmpphp/. I wrote a bot myself based on it. In principle, with a little dopilivanie quite a working tool.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question