ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

What is the difference between publisher-subscriber vs. server-client?

asked 2018-07-25 09:56:56 -0500

gabi gravatar image

I just completed the beginner tutorial and I do not understand the difference between the publisher-subscriber (PS) way of passing messages and the server-client (SC) way of passing messages. To me they seem like two ways of doing the same thing.

If I understand correctly, with the PS method there is a queue. P pushes messages in the queue and S listens for messages coming from the queue.

In SC, there is no queue, instead C waits for S to make some sort of action and then executes.

What is the practical difference between the two ways?

In what situation should I use one and not the other?

edit retag flag offensive close merge delete

Comments

1

Almost a duplicate: #q237672.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-25 10:10:53 -0500 )edit
2

ok thanks, but it doesn't answer any of my questions

gabi gravatar image gabi  ( 2018-07-26 04:48:33 -0500 )edit

The paper that is linked in #q237672 may be a bit academic, but it actually answers all your questions.

If you're happy with the explanation you received from your friend though, we're happy.

Know that there is a bit more to pub-sub vs client-server than you write in your answer below.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-26 04:51:11 -0500 )edit
2

True, maybe it does and yes I did not read it. I guess I expected a tl;dr helpful answer instead of 'go read this 18 page paper'

gabi gravatar image gabi  ( 2018-07-26 04:52:46 -0500 )edit

The answer you posted below is perfectly fine for a "tl;dr" helpful answer.

I only referred you to the paper in case you wanted more insight into the differences. I don't believe "go read this 18 page paper" was said to you anywhere.

Also: the differences are explained in sections 2 and 3, ..

gvdhoorn gravatar image gvdhoorn  ( 2018-07-26 04:59:13 -0500 )edit

.. which are 4 pages of A4 text at most.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-26 04:59:39 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
5

answered 2018-07-26 04:45:56 -0500

gabi gravatar image

I ended up getting the answer to my questions by asking a friend:

Q: what is the difference?

A: Pubsub tends to be for different purposes: you subscribe to something, process it and publish it. Usually at a fairly fixed rate. You can subscribe to multiple things and publish multiple things. Multiple other nodes can subscribe to the same topic. You can even have multiple nodes publishing to the same topic.

Server client tends to be more request response. Ros can also do that, see Ros services or Ros action server. In client server a client makes an explicit request for some specific data.

Q: in which scenario would I use one over the other?

A: You can do a request like structure in pubsub, but that's not really the aim. Pubsub is super flexible in that sense. But if you need to process specific requests from clients pubsub gets tricky, because all topics are global. For example, in pubsub, if client a and b make a request and you process them and output two responses, how do they know which one was for a and which one for b? That is the benefit of server client over pubsub: server client makes explicit requests, while pubsub makes information global.

edit flag offensive delete link more

Comments

What does "For example, in pubsub, if client a and b make a request and you process them and output two responses, how do they know which one was for a and which one for b?" mean?

Shivam gravatar image Shivam  ( 2021-10-03 21:07:13 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-07-25 09:56:56 -0500

Seen: 9,626 times

Last updated: Jul 26 '18