Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slowness at reading many retained messages #9

Open
leandronsp opened this issue Aug 6, 2018 · 0 comments
Open

Slowness at reading many retained messages #9

leandronsp opened this issue Aug 6, 2018 · 0 comments

Comments

@leandronsp
Copy link

Hey!

I'm around an issue which I'm not sure if it's related how I use the lib or something else on its internals.
By trying the following process:

@mqtt_client = PahoMqtt::Client.new(
  client_id: client_id,             
  username: username,               
  password: password                
)

@mqtt_client.connect(
  host=@mqtt_host,   
  port=@mqtt_port,   
  keep_alive=60,     
  persistent=true    
)

@mqtt_client.subscribe(['v1/some_topic'], 1) 

@mqtt_client.on_message do |message|                                       
  # print the retained/received message
end

At first, it will print all retained messages on the broker, around ~80 on ours.
It takes 10 seconds to load all 80 retained messages, which it seems to be very slow on our requirements.

Then I changed to use the foreground alternative.

@mqtt_client.connect(
  host=@mqtt_host,   
  port=@mqtt_port,   
  keep_alive=60,     
  persistent=true ,
  blocking=true  
)

def foreground_mode                                     
  [:loop_read, :loop_write, :loop_misc].each do |method|
    Thread.new do                                       
      while @mqtt_client.connected? do                  
        @mqtt_client.send(method)                       
      end                                               
    end                                                 
  end                                                   
end                                                     

# will spawn a different Thread for each loop
foreground_mode

Even so, this solution is even worse, taking 40 seconds, and I think it's related to the GIL maybe.

In addition, I compared along with the paho.mqtt.python lib, which in turn takes just 1 second instead to load all 80 retained messages. I'd gently ask you guys for some clue, am I missing something, some tweak to be made, already an known issue?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant