title: How to publish multiple messages in google Pub/Sub fast?
body: <p>How to publish multiple messages to pubsub fast? Without multiprocessing and multithreading becaue the code is already in a Thread</p>
  <p>The code bellow is publishing 40 messages per second</p>
  <pre><code>publisher = pubsub.PublisherClient(
      credentials=credentials,
      batch_settings=types.BatchSettings(
           max_messages=1000,  # default is 100
          max_bytes=1 * 1000 * 1000,  # 1 MiB
          max_latency=0.1,  # default is 10 ms
      )
  )
  
  topic_name = 'projects/{project_id}/topics/{topic}'.format(
      project_id=PROJECT_ID,
      topic=TOPIC_PUBSUB,
  )
  
  for data in results:
      bytes_json_data = str.encode(json.dumps(data))
      future = publisher.publish(topic_name, bytes_json_data)
      future.result()
  </code></pre>