[glance] Slow image download when using glanceclient

Sean Mooney smooney at redhat.com
Thu Oct 13 17:18:17 UTC 2022


On Thu, 2022-10-13 at 13:30 -0300, Lucio Seki wrote:
> Hi glance experts,
> 
> I'm using the following code to download a glance image:
> 
> ```
> from glanceapi import client
> ...
> glance = client.Client(GLANCE_API_VERSION, session=sess)
> ...
> with open(path, 'wb') as image_file:
>     data = glance.images.data(image_id)
>     for chunk in tqdm(data, unit='B', unit_scale=True, unit_divisor=1024):
>         image_file.write(chunk)
> ```
> 
> And I get a speed around 3kB/s. It would take months to download an image.
> I'm using python3-glanceclient==3.6.0.
> I even tried:
> ```
>     for chunk in tqdm(data, unit='B', unit_scale=True, unit_divisor=1024):
>         pass
> ```
> to see if the bottleneck was the disk I/O, but didn't get any faster.
> 
> In the same environment, when I use the glance CLI instead:
> 
> ```
> glance image-download --file $path $image_id
> ```
> I get hundreds of MB/s download speed, and it finishes in a few minutes.
> 
> Is there anything I can do to improve the glanceclient performance?
> I'm considering using subprocess.Popen(['glance', 'image-download', ...])
> if nothing helps...
have you considered using the openstacksdk instead

the glanceclint is really only intendeted for other openstack service to use like
nova or ironic.
its not really ment to be used to write your onw code anymore.
in the past it provided a programatic interface for interacting with glance
but now you shoudl prefer the openstack sdk instead.
https://github.com/openstack/openstacksdk

> 
> Regards,
> Lucio




More information about the openstack-discuss mailing list