Giter Site home page Giter Site logo

iron-io / functions Goto Github PK

View Code? Open in Web Editor NEW
3.2K 105.0 227.0 6.92 MB

IronFunctions - the serverless microservices platform by

Home Page: https://iron.io

License: Apache License 2.0

Go 96.53% Shell 1.11% Makefile 0.50% Ruby 1.43% PowerShell 0.26% Dockerfile 0.18%
serverless faas docker lambda

functions's People

Contributors

adelevie avatar alnutile avatar auyer avatar bupychuk avatar c0ze avatar ccirello avatar denismakogon avatar derekschultz avatar edsrzf avatar ekalinin avatar gouthamve avatar guilhermebr avatar henriquechehad avatar jconning avatar jmank88 avatar kunihiko-t avatar lingxiankong avatar martinpinto avatar merqlove avatar michaelkitson avatar nii236 avatar nikhilm avatar noqcks avatar pedronasser avatar seiflotfy avatar sks avatar thousandsofthem avatar treeder avatar ucirello avatar wjimenez5271 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

functions's Issues

Emit Metrics to Logs

Using log format defined here: https://github.com/iron-io/logspout-statsd

Eg:

metric=someevent value=1 type=count
metric=somegauge value=50 type=gauge

Emit the following metrics (at least):

  • wait time total (all apps)
  • wait time per function
  • execution time total (all apps)
  • execution time per function
  • function request count
  • function error count
  • cpu/memory per function ?

Make "function tool" in ironcli

Say you make a directory for each function, the tool will go through each directory and check for changes, if changed, bump a version number (use the same type of script we use in release.sh? or check for a VERSION file and bump that), then run docker build, tag it with version, then docker push, then update route in IronFunctions.

Should think about some way to help with testing too, like build, then run tests against the container?

See: https://github.com/iron-io/functions/tree/master/tool

and/or build this into serverless framework?

Async functions

First PR #97

This issue is for discussion and feedback on the functionality.

Dynamic routes: Can we optimize the route matching rather than pulling up all routes for an app?

This is tricky because of this: #71

ie: https://github.com/iron-io/functions/pull/74/files#diff-e180f07f5c320b82004c2bb065eedef0R99

The problem is we'd like to query for a single route, but let's say the route is defined as:

/blogs/:blog_id/comments/:comment_id

And a request comes in for:

/blogs/123/comments/456

How do we query the database for the route metadata with only that information? Could query for /blogs/123/comments/456, which is the static default way. But that wouldn't match. We could try all variations, eg /blogs/123/comments/* and /blogs/123/*/456, and /blogs/123/*/*, and so on, but that wouldn't be very efficient.

To summarize, the problem here is:

Given a path and only a path, eg: /blogs/travisblog/comments/123 what should you query for? Not knowing what routes exist before hand.

Docs and example of autoscaling

Collect some metrics (function wait time probably good?) from logs then launch new server(s) based on that. Use something like Kubernetes or operator to keep it simple. Needs to be added to load balancer automatically too.

Response on create app should use app wrapper

Currently returns:

✗ curl -H "Content-Type: application/json" -X POST -d '{
quote>     "app": { "name":"myapp5" }
quote> }' http://functions.iron.io/v1/apps
{"name":"myapp5"}

Return the "app" wrapper, same as the input. And also add a "message" or "msg" that says "App created successfully".

Support for params in route paths

eg: /r/myapp/somethings/:something_id/comments/:comment_id => PARAM_SOMETHING_ID=X and PARAM_COMMENT_ID=Y

Also add METHOD=GET/POST env vars.

re: #56

[WIP] CRON like scheduling / scheduler

Triggers functions on a repeating schedule.

Use new input format discussed recently and probably CRON format as well.


Proposal for cron support

Basic architecture sketch for each IronFunctions node:

                 ┌────────┐
     ┌──────────▶│D. Lock │
     │           └────────┘
     │
┌────────┐       ┌────────┐
│  Cron  │──────▶│   DB   │◀─────────────┐
└────────┘       └────────┘              │
     │                                   │
     │           ┌────────┐         ┌────────┐
     └──────────▶│   MQ   │◀────────│  HTTP  │
                 └────────┘         └────────┘
                      ▲                  │
                      │                  │
                      │                  ▼
                 ┌────────┐         ┌────────┐
                 │ Async  │         │  Sync  │
                 └────────┘         └────────┘

The two additional components are:

D. Lock is a some sort of distributed lock offered by latest versions of etcd
and Consul. In theory, any distributed lock would be enough in order to achieve
the necessary role in this design.

Cron is a gear similar to async. It enqueues a cron job while holding a
distributed mutex lock. Its implementation would be similar to the following:

lock()
jobs := cronjobs()
for _, job := range jobs {
	ls := laststart(j)
	if job.shouldRunAfter(ls) {
		ls.touch()
		enqueue(j)
	}
}
unlock()

In the DB, the new datastructure would be:

[{
	"id": "...",
	"function": {
		"app": "app",
		"path": "/fn",
		"headers": ["Context-Type: application/json"],
		"body": "....",
	}
	"frequency": "*/10 * * * *"
}, ...]

id is a unique identifier for the cronjob. It aims to allow repeated entries
for a same given function.

function is the description of the function to be ran. It will mimic a HTTP
POST call with headers and body. It also adds a User-Agent with the
specific information that this call is made by the cron worker.

frequency is a crond-like string that specifies when should this cronjob be
ran.

Restricting the distributed lock to etcd/consul and alikes, it means they can
also be used as an authoritative key-value source of truth regarding the last
execution.

laststart in the example code above, is the last time this cronjob was started,
regardless of success or failure.

Test suite to test API

Builds the image, starts the API, then:

  • Test all API endpoints
  • Tests some routes, such as hello world one and checks to see that response is valid (headers and body)
  • Test an error route (iron/error image is a container that just errors out, good for testing). Ensure error status code.

Long(er) running containers for better performance aka Hot Containers

Instead of one off execution, keep container running for a while and take requests.

The first version executes a container per function call/request. Which is fine for many things, but we may want a way to run for longer periods of time to increase performance due to things like keeping db connections open, etc.

This would probably require a more lambda like code format and language libraries. See https://github.com/iron-io/lambda for existing work on lambda style code format.

I created a prototype of this years ago that routed traffic into IronWorker containers, should dig that out and look into that implementation.

New Postgres bugs

There was this one: 662216f

And now I get this one after that fix:

RRO[0086] Could not create app                          action=server.handleAppCreate error=pq: column "config" of relation "apps" does not exist

@pedronasser looks like you may have broken this with your config changes. Can you please fix, thanks.

Full App/Microservice example

An example that builds a full API with multiple endpoints, authentication, etc.

Take a blog example or something and build it using IronFunctions.

  • GET /posts returns list of posts
  • POST /posts adds a new post and stores it in a database (a database that requires auth like a postgres database hosted on heroku or something). Requires authentication (JWT token in header).
  • GET /posts/:id returns a full post.

Get rid of these errors in the logs or deal with them better so they aren't errors

ERRO[0456] error streaming docker stats for task         container=task-a790dc09-7149-58eb-b8ef-bdc1571ad2c5 error=io: read/write on closed pipe task_id=a790dc09-7149-58eb-b8ef-bdc1571ad2c5
ERRO[0459] Handler for POST /containers/task-a790dc09-7149-58eb-b8ef-bdc1571ad2c5/stop returned error: Container task-a790dc09-7149-58eb-b8ef-bdc1571ad2c5 is already stopped

The function appears to execute and respond just fine, but these errors show up every time.

For STDERR logging, use this format

Take STDERR from runner containers and add app_name, path, function, request_id and put the actual log line in msg. If using logrus, it will automatically use msg.

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.