Hello,

if this optimization (using FileResponse) is not enough for your use case, that's maybe only because the connection is not fast enough between the server and your client.

As you said, the only solution is to increase Gunicorn timeout.


Rgds

Le jeu. 9 janv. 2020 à 08:34, Larry Shen <larry.shen@nxp.com> a écrit :

Hi, Remi,

 

As 2019.12 release has some folder structure changes, so I just add your modify to “/usr/lib/python3/dist-packages/lava_rest_app/api.py” as my local master do not have base folder.

But unfortunately, this didn’t help, as you said use “FileResponse” could increase efficiency, but gunicorn is before Django, I don’t know.

 

Still, as I said before, modify “/lib/systemd/system/lava-server-gunicorn.service”

Change “ExecStart=/usr/bin/gunicorn3 lava_server.wsgi --log-level $LOGLEVEL --log-file $LOGFILE -u lavaserver -g lavaserver --workers $WORKERS $RELOAD $BIND” to

“ExecStart=/usr/bin/gunicorn3 lava_server.wsgi --log-level $LOGLEVEL --timeout=600 --log-file $LOGFILE -u lavaserver -g lavaserver --workers $WORKERS $RELOAD $BIND” works for me.

 

Anyway, maybe my check with your code is wrong. I’m not hurry, I could wait for your final 2020.01 release, then try again, thanks.

 

From: Remi Duraffort <remi.duraffort@linaro.org>
Sent: Thursday, January 9, 2020 2:48 PM
To: Larry Shen <larry.shen@nxp.com>
Cc: Milosz Wasilewski <milosz.wasilewski@linaro.org>; lava-users@lists.lavasoftware.org
Subject: Re: [Lava-users] [EXT] Re: lavacli cannot fetch big logs.

 

Caution: EXT Email

Hello,

 

thanks for the detailed logs.

 

I believe that this should be fixed by https://git.lavasoftware.org/lava/lava/merge_requests/911

 

 

Rgds

 

Le jeu. 9 janv. 2020 à 07:15, Larry Shen <larry.shen@nxp.com> a écrit :

Hi, Remi,

 

Next is the log, you can see it always stop at about 30 seconds, if log smaller, its ok.

So, have your 1.3G log been fetch in 30 seconds? I think this not just related the log size, also related to the network, pc capability etc. If it could be fetched among 30 seconds, even bigger log is ok.

We use 2019.11 versions master.

 

$ time wget http://lava-master.sw.nxp.com/api/v0.1/jobs/30686/logs

--2020-01-09 14:01:57--  http://lava-master.sw.nxp.com/api/v0.1/jobs/30686/logs

Resolving lava-master.sw.nxp.com (lava-master.sw.nxp.com)... 134.27.169.17

Connecting to lava-master.sw.nxp.com (lava-master.sw.nxp.com)|134.27.169.17|:80... connected.

HTTP request sent, awaiting response... 301 Moved Permanently

Location: /api/v0.1/jobs/30686/logs/ [following]

--2020-01-09 14:01:58--  http://lava-master.sw.nxp.com/api/v0.1/jobs/30686/logs/

Reusing existing connection to lava-master.sw.nxp.com:80.

HTTP request sent, awaiting response... 200 OK

Length: 275583101 (263M) [application/yaml]

Saving to: logs

 

logs                                     77%[==========================================================>                  ] 202.48M  10.2MB/s    in 31s

 

2020-01-09 14:02:29 (6.55 MB/s) - Connection closed at byte 212318286. Retrying.

 

--2020-01-09 14:02:30--  (try: 2)  http://lava-master.sw.nxp.com/api/v0.1/jobs/30686/logs/

Connecting to lava-master.sw.nxp.com (lava-master.sw.nxp.com)|134.27.169.17|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 275583101 (263M) [application/yaml]

Saving to: logs

 

logs                                     94%[=======================================================================>     ] 247.13M  8.35MB/s    in 31s

 

2020-01-09 14:03:03 (7.88 MB/s) - Connection closed at byte 259138631. Retrying.

 

--2020-01-09 14:03:05--  (try: 3)  http://lava-master.sw.nxp.com/api/v0.1/jobs/30686/logs/

Connecting to lava-master.sw.nxp.com (lava-master.sw.nxp.com)|134.27.169.17|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 275583101 (263M) [application/yaml]

Saving to: logs

 

logs                                      7%[====>                                                                        ]  19.40M  5.34MB/s    eta 53s    ^C

 

real    1m12.372s

user    0m0.402s

sys     0m3.103s

 

 

With curl:

 

time curl -L http://lava-master.sw.nxp.com/api/v0.1/jobs/30686/logs > aa

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

24  262M   24 63.5M    0     0  1950k      0  0:02:17  0:00:33  0:01:44 5395k

curl: (18) transfer closed with 208899007 bytes remaining to read

 

real    0m33.397s

user    0m0.151s

sys     0m0.593s

 

 

What I miss?

 

From: Remi Duraffort <remi.duraffort@linaro.org>
Sent: Wednesday, January 8, 2020 11:56 PM
To: Milosz Wasilewski <milosz.wasilewski@linaro.org>
Cc: Larry Shen <larry.shen@nxp.com>; lava-users@lists.lavasoftware.org
Subject: Re: [Lava-users] [EXT] Re: lavacli cannot fetch big logs.

 

Caution: EXT Email

Hello,

 

I tried locally with a log file of 1.1G and lavacli fails while the rest api works.

 

Which version of LAVA are you using?

 

I looked at ways to improve the speed for both xmlrpc and the rest api.

 

For xmlrpc, the main problem is the fact that the data is loaded in memory and then base64 encoded and then send back to the user. Nothing we can do about this without writing our own xmlrpc library (or improving the official library).

 

For the rest api, we can use FileResponse instead of HttpResponse to improve performance. On my local setup the download is now 60% faster. I will send a merge request.

 

 

Rgds

 

 

Le mer. 8 janv. 2020 à 11:15, Milosz Wasilewski <milosz.wasilewski@linaro.org> a écrit :

On Wed, 8 Jan 2020 at 09:56, Larry Shen <larry.shen@nxp.com> wrote:
>
> Yes, Milosz,
>
> 57MB is fine, in fact, our 100M+ also fine, just if bigger, like 270MB, it will not fine.

ah, ok. I thought there was some other issue with cli.

>
> I guess it related to gunicorn timeout, if not able to read all log among the timeout, it will fail.
>
> I tried your suggestion, but even I switch to use rest api, it will also timeout as it also go the way gunicorn.
>
> I found this:
>
> https://docs.gunicorn.org/en/stable/settings.html#timeout
>
> It said:
>
> > Default gunicorn was set 30 seconds for worker timeout.
>
> It seems I have to change " /lib/systemd/system/ lava-server-gunicorn.service" to enlarger the timeout. Just wonder in the day which async http server so popular, if possible lava could adopt some such kinds of technology? Like next: https://docs.gunicorn.org/en/stable/design.html#async-workers
>
> Or any other suggestion you could give for this gunicorn worker timeout, I mean short turn solution...

I'll defer to Remi. IMHO it would make sense to implement streaming
response somewhere. The down side is you don't know the download size
in advance but it should not time out.

milosz

>
> -----Original Message-----
> From: Milosz Wasilewski <milosz.wasilewski@linaro.org>
> Sent: Wednesday, January 8, 2020 5:07 PM
> To: Larry Shen <larry.shen@nxp.com>
> Cc: lava-users@lists.lavasoftware.org
> Subject: [EXT] Re: [Lava-users] lavacli cannot fetch big logs.
>
> Caution: EXT Email
>
> On Wed, 8 Jan 2020 at 08:18, Larry Shen <larry.shen@nxp.com> wrote:
> >
> > Hi, there,
> >
> >
> >
> > We have one job to do some stress test, the final log is about 270MB.
> >
> >
> >
> > We use `lavacli -i production jobs logs --raw 30686` to fetch the log, it gives me next:
> >
> >
> >
> > ```
> >
> > $ time lavacli -i production jobs logs --raw 30686
> >
> > /usr/lib/python3/dist-packages/lavacli/__init__.py:101: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmsg.pyyaml.org%2Fload&amp;data=02%7C01%7Clarry.shen%40nxp.com%7Ca778c428e4a947d9b3ab08d7941a20f6%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637140712254316438&amp;sdata=06j7jwCcUHSkcBHDzKYScsdqjqhyQnpOKiLgDqk2CmY%3D&amp;reserved=0 for full details.
> >
> >   config = yaml.load(f_conf.read())
> >
> > Unable to call 'jobs.logs': <ProtocolError for
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flarry
> > .shen%3Axxx%40xxx.nxp.com%2FRPC2&amp;data=02%7C01%7Clarry.shen%40nxp.c
> > om%7Ca778c428e4a947d9b3ab08d7941a20f6%7C686ea1d3bc2b4c6fa92cd99c5c3016
> > 35%7C0%7C0%7C637140712254316438&amp;sdata=t2frtOwreMTjSSVMDca1ob2T5M0%
> > 2B8QCpBcaXUL1tArc%3D&amp;reserved=0: 500 ('Connection broken:
> > IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))>
> >
> >
> >
> > real    0m39.006s
> >
> > user    0m0.989s
> >
> > sys     0m0.191s
> >
> > ```
> >
> >
> >
> > I check the gunicorn log, it give me:
> >
> > [2020-01-08 08:11:12 +0000] [188] [CRITICAL] WORKER TIMEOUT
> > (pid:11506)
> >
> >
> >
> > Any suggestion?
>
> you can try using API instead
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fyour.instance.url%2Fapi%2Fv0.2%2Fjobs%2F30686%2Flogs&amp;data=02%7C01%7Clarry.shen%40nxp.com%7Ca778c428e4a947d9b3ab08d7941a20f6%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637140712254326435&amp;sdata=ZYGbpEAD%2B6LAKiNdLj2EgmfJiIvtVeoXfylpW%2Fqlg3A%3D&amp;reserved=0
>
> I just fetched 57MB log and it worked just fine. In the long run we can probably switch lavacli to use REST API.
>
> milosz
>
> >
> > _______________________________________________
> > Lava-users mailing list
> > Lava-users@lists.lavasoftware.org
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
> > s.lavasoftware.org%2Fmailman%2Flistinfo%2Flava-users&amp;data=02%7C01%
> > 7Clarry.shen%40nxp.com%7Ca778c428e4a947d9b3ab08d7941a20f6%7C686ea1d3bc
> > 2b4c6fa92cd99c5c301635%7C0%7C0%7C637140712254326435&amp;sdata=s2KqYKrm
> > PfCEBOSjF93IpV07I0P6iMp5zQtRRDfYgjU%3D&amp;reserved=0

_______________________________________________
Lava-users mailing list
Lava-users@lists.lavasoftware.org
https://lists.lavasoftware.org/mailman/listinfo/lava-users


 

--

Rémi Duraffort

LAVA Architect

Linaro


 

--

Rémi Duraffort

LAVA Architect

Linaro



--
Rémi Duraffort
LAVA Architect
Linaro