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

Can I run this with OpenFaaS / open-source FaaS? #12

Closed
alexellis opened this issue Nov 28, 2017 · 12 comments
Closed

Can I run this with OpenFaaS / open-source FaaS? #12

alexellis opened this issue Nov 28, 2017 · 12 comments

Comments

@alexellis
Copy link

Would I be able to run this on OpenFaaS' Python runtime?

https://github.com/openfaas-incubator/python3-debian

I can do a build following the instructions but it seems to reach out to a Lambda/AWS region.

@FutureSharks
Copy link
Owner

I don't know what that is but you can simply use the first example:
https://github.com/FutureSharks/invokust#examples
This doesn't use Lambda.

@alexellis
Copy link
Author

alexellis commented Nov 29, 2017

It's Serverless FaaS but open-source (rather than proprietary/cloud-hosted) OpenFaaS/faas. This is what I managed to put together - https://github.com/alexellis/locust-openfaas

What do you think?

@FutureSharks
Copy link
Owner

I see, interesting! Looks OK but using subprocess is a bit hacky for something that is supposed to be serverless?

If I was you, in locust/index.py, I would copy the code from my example and then return/print the stats.

@alexellis
Copy link
Author

alexellis commented Nov 29, 2017

Creating a subprocess via the handler doesn't make it any more or less serverless. I couldn't find out how to launch locust without using their binary / helper, but if you have a way I'd be interested in changing over to it.

I think I tried your code last night but it had a boto3 or Lambda session reference somewhere that stopped it from working. Have you tried locust/index.py in a regular Docker container for instance?

@FutureSharks
Copy link
Owner

FutureSharks commented Nov 29, 2017

Creating a subprocess via the handler doesn't make it any more or less serverless.

OK fair enough 👍

I couldn't find out how to launch locust without using their binary / helper

That is exactly what this project does, as per the first example.

I think I tried your code last night but it had a boto3 or Lambda session reference somewhere that stopped it from working.

If you be specific, I'd be happy to help!

Have you tried locust/index.py in a regular Docker container for instance?

Nope.

@alexellis
Copy link
Author

alexellis commented Nov 29, 2017

Code:

import invokust

from locust import HttpLocust, TaskSet, task

class Task(TaskSet):
    @task()
    def get_home_page(self):
        '''
        Gets /
        '''
        self.client.get("/")

class WebsiteUser(HttpLocust):
    task_set = Task

settings = invokust.create_settings(
    classes=[WebsiteUser],
    host='http://www.openfaas.com',
    num_requests=10,
    num_clients=1,
    hatch_rate=1
    )

loadtest = invokust.LocustLoadTest(settings)
loadtest.run()
loadtest.stats()

Error:

Traceback (most recent call last):
  File "index.py", line 1, in <module>
    import invokust
  File "/usr/local/lib/python3.6/site-packages/invokust/__init__.py", line 5, in <module>
    from .aws_lambda import get_lambda_runtime_info
  File "/usr/local/lib/python3.6/site-packages/invokust/aws_lambda/__init__.py", line 4, in <module>
    from .lambda_load_test import LambdaLoadTest
  File "/usr/local/lib/python3.6/site-packages/invokust/aws_lambda/lambda_load_test.py", line 17, in <module>
    client = session.client('lambda', config=config)
  File "/usr/local/lib/python3.6/site-packages/boto3/session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "/usr/local/lib/python3.6/site-packages/botocore/session.py", line 861, in create_client
    client_config=config, api_version=api_version)
  File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 73, in create_client
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 285, in _get_client_args
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/usr/local/lib/python3.6/site-packages/botocore/args.py", line 45, in get_client_args
    endpoint_url, is_secure, scoped_config)
  File "/usr/local/lib/python3.6/site-packages/botocore/args.py", line 111, in compute_client_args
    service_name, region_name, endpoint_url, is_secure)
  File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 358, in resolve
    service_name, region_name)
  File "/usr/local/lib/python3.6/site-packages/botocore/regions.py", line 122, in construct_endpoint
    partition, service_name, region_name)
  File "/usr/local/lib/python3.6/site-packages/botocore/regions.py", line 135, in _endpoint_for_partition
    raise NoRegionError()
botocore.exceptions.NoRegionError: You must specify a region.

@alexellis
Copy link
Author

Btw I also saw you have an interest in RPi - OpenFaaS also runs natively on Raspberry Pi and 64-bit ARM.

Let me know if you can push a fix up for testing that doesn't try to load boto and all that other Lambda stuff.

@FutureSharks
Copy link
Owner

Thanks!

I'll definitely fix it. Your use case sounds interesting. But it will take me a few days as I have little free time right now.

In the mean time, as a workaround for you, you can set an env var AWS_DEFAULT_REGION=eu-west-1 to stop the error.

@FutureSharks
Copy link
Owner

Hi @alexellis could you test this PR and see if it solves the problem for you?
#14

@FutureSharks
Copy link
Owner

Any update on this issue?

@alexellis
Copy link
Author

alexellis commented Jan 29, 2018

This is as far as I got - https://github.com/alexellis/locust-openfaas - it is working with the regular locust framework rather than the invokust wrapper. It would still be nice to get invokust working w/o a hard dependency on Lambda.

I'm really busy trying to get a new release out.. Would you be willing to spend a bit of time on it?

@FutureSharks
Copy link
Owner

Would you be willing to spend a bit of time on it?

Spend more time on what? I fixed your issue in PR 14: #14
I'm waiting for you to test it.

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

2 participants