It does not have to be the same size(group 24, 27, 31, etc). If you are running a 24V system, the smaller battery will die 1st. If you are running them in series (12V), I dont think it will make any difference as both batteries will discharge at the same rate, they will act as 1 battery(90% sure I am right on that).
If you are running 24V, I would recommend running the same battery for consistant performance, there will be a considerable loss of voltage as the smaller battery is losing charge and your electronics will not perform properly.