Git Product home page Git Product logo

Comments (12)

alexellis avatar alexellis commented on May 12, 2024

Hi @gijswobben thanks for testing out FaaS. It would be great if you could fill out the issue template which was provided when you opened the issue.

Please let us know some more details

  • Runtime (Node/Python/Go etc)
  • Backend - Swarm or Kubernetes
  • How long it takes to run your requests

Also if you can share code or push it to a private/public repo that would help.

from faas.

gijswobben avatar gijswobben commented on May 12, 2024

The template didn't seem applicable as this is a question (not an issue).. Everything is working fine, I was just wondering if I could speed things up. The initialization of my script cannot run any faster because it has to load some libraries and models from disk. After that I can use a very fast function to do something. I'd love to cache the libraries and models so my function can execute faster.

Runtime -> R (or Python) for data science (XGBoost model)
Backend -> Swarm
Function run time when all libraries are loaded 33ms, initialization time 1.5s

from faas.

alexellis avatar alexellis commented on May 12, 2024

The function watchdog works by forking a process - reading the entire body and then piping that to stdin, anything written to stdout is returned to the caller. So reusing the process as it is, would not possible, however there are some work-arounds that other people are using:

  • Batching - Instead of calling the function 1k times with 1 piece of data each time, call the function with a batch of 1k data items. It may involve a helper bash script
  • Use the asynchronous work - This model is perfect for TensorFlow and machine learning - since you can run the requests for much longer - https://gist.github.com/alexellis/62dad83b11890962ba49042afe258bb1
  • Implement the watchdog interface - As long as you expose a port on 8080 and act like the watchdog FaaS will still manage your container, track metrics and scale it. You could use flask for this.
  • Create a microservice - Create a microservice that is long running and let your function handle the ingestion of data - passing it on to the (XGBoost / R service) and returning the results.

from faas.

alexellis avatar alexellis commented on May 12, 2024

Hi, @gijswobben it's been 16 days since my response so I'll close this issue. Please do re-open if you need to, or join us on Slack to chat about any of the solutions outlined above.

from faas.

alexellis avatar alexellis commented on May 12, 2024

@gijswobben I've had a chance to revisit this item and I think I have a technical approach for helping with this. Did you try any of the outlined solutions? Do you have an example online somewhere?

from faas.

gijswobben avatar gijswobben commented on May 12, 2024

I've tried the first approach and the second. The last 2 are no option for me, in my opinion they introduce too much overhead code for something that should be a "function as a service"...

The approaches I did try work, but there is still a lot of overhead. I'm dealing with large quantities of data so even with the batching approach there is a lot of overhead. I don't have an example online since I'm developing this for a customer...

I'm curious to hear your solution. I think the only way to go here is to keep the function open and direct all new requests to this function, reading and writing over STDIN and STDOUT line by line. However, this solution would require quite some changes to watchdog.

from faas.

alexellis avatar alexellis commented on May 12, 2024

Regarding 1 & 2 - batching data and running async would make a huge dent in the issue. The asynchronous work was merged and is available in 0.6.2. https://github.com/alexellis/faas/releases/tag/0.6.2

I have made the changes to the watchdog (not yet available on GitHub) and did some testing - it's blisteringly fast. This is the JVM & Java - https://www.youtube.com/watch?v=gG6z-4a1gpQ

Join us on Slack and let's do some testing with the new approach? email [email protected]

from faas.

gijswobben avatar gijswobben commented on May 12, 2024

Thanks, I give it a try

from faas.

gijswobben avatar gijswobben commented on May 12, 2024

Performance is okay.. Certainly not what I hoped for but it gets the job done. What you show in you're video is indeed a fast example, however, try to add a 15 second delay to the initialization of your function and run it again. The startup cost (in this case the delay) is so high that it will ruin your performance.

I think we can close this issue. Thank you very much for the effort and a workable solution!

from faas.

alexellis avatar alexellis commented on May 12, 2024

I think you might be going about it a different way to intended.

If you need a 15 second boot-up - then you need it, nobody can change that - but you can put it into the initialiser and not the handler 👍

Maybe you can explain what you mean?

from faas.

gijswobben avatar gijswobben commented on May 12, 2024

Totally agreed, I cannot avoid the 15 second boot-up. However, it would be nice if I didn't have to wait that 15 seconds with every new call. It would be great to have such an "initialiser". Run the initialiser once, and than run the handler as many times as needed (for every call). However, looking through the documentation and code, there is no way to do such an initialisation right now, is there?

from faas.

alexellis avatar alexellis commented on May 12, 2024

No you could add an explicit initialisation separately. We can adjust the template for that or you could do something simple like write a lock file to understand whether to run the initialization a second time.

from faas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.