Adult Content Warning

This community may contain adult content that is not suitable for minors. By closing this dialog box or continuing to navigate this site, you certify that you are 18 years of age and consent to view adult content.

Programming -- shell / java / c# / python / ada / lisp

Discussion in 'Technical Board' started by Nettdata, Dec 1, 2009.

  1. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,751
    Joined:
    Feb 14, 2006
    Messages:
    17,417
    Sure...

    "Normal" or classical app development means that you write an app, and then launch it in a server somewhere. That server is running an OS, an app server (like Apache), and then an application (like Django, etc). That means that the application is running 24x7 in that machine, and the machine is up and running 24x7.

    Serverless is different in that there is no OS, or machine that is spun up. Instead, there is a small piece of code (sometimes called a Lambda) that does one small specific piece of functionality. That code is uploaded to the cloud, and has an "activated by" or "triggered by" element, like an API call. You basically configure it so that when a specific REST endpoint is called, it runs that one piece of code that you've uploaded as the lambda. When it's done running, it goes away.

    It's used a lot with IOT (internet of things) programming where you might want to just capture small pieces of data and store them, for example... like a smart hydro meter, for example. Every 30 minutes, your meter will spin up, and then hit that REST endpoint. When that endpoint is called, it then runs that Lambda, and executes it with the data that is passed into it from that REST call. In some cases, that Lambda can be a Node.js snippet, which takes that data, parses the data, connects into a database, stores that data, and then shuts down and the Lambda/code-snippet is deleted.

    It's meant for more simplistic, very event-driven applications. It's designed to take advantage of all the unused, unallocated resources that AWS has that are sitting there doing nothing. You only pay fractions of pennies for each time the Lamda is run, rather than tens or hundres of dollars a month for a constantly running server.

    Serverless is able to scale way, way, WAY beyond the capacity of a normal instance that you'd spin up. For example, AWS EC2 has a number of instance sizes with various resource limits; memory, cpu, disk space, etc. You can spin up the box at a specific monthly cost for the use of those resources.

    Serverless let's you forget about that instance size... if you have 1 person hitting your API and triggering the lambda, you only get billed for that 1 person hitting that lambda. You can also have 10 million people hit that same endpoint and run that same lambda code 10 million times, simultaneously, so you can scale on demand so much easier than having to try and scale out EC2 instances to handle your scale, etc.

    It's pretty easy to understand how code snippets can be run as Lambdas, but the database stuff can be a bit harder to wrap your head around.

    That blog post I linked to earlier explains it, but it takes the storage of the database (which is stored in S3), and then only interacts with it when it needs to using that "on-demand" lambda like interaction, except with the DBMS (mysql). So when you need to store data, it grabs an available Mysql executable (that is running somewhere in their available resources in AWS), and then it connects quickly to your specific data files in S3, does it's thing, then spins down the Mysql executable. That means you don't have to pay for the instance to run mysql or postgres 24x7, it's only being spun up and used when it's actually being called.



    That's kind of a high overview... and I'm a bit drunk... so let me know if you need any clarification.

    This page gives you a bit of a high-level overview: https://aws.amazon.com/serverless/
     
  2. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    1
    Joined:
    Oct 19, 2009
    Messages:
    493
    Okay, I think I got it. I appreciate the explanation. After I build these DJANGO apps I'll probably look into learning that next.
     
  3. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,751
    Joined:
    Feb 14, 2006
    Messages:
    17,417
    Simply stated:

    Server-based = spin up a server with 2 CPU's, 8GB of RAM, 150GB of hard drive... run an app in it, 24x7, waiting for user to hit it... you're paying for it regardless of whether it's being used or not, and it will max out at some amount of traffic because of those server specs. It's like a remote machine you're renting in the Cloud. (Cloud just means "someone else's computer"). Billed at something like $150/month, regardless of use.

    "Serverless" basically means you break down your app into small pieces, and then store those pieces of application code in the cloud. Those code snippets are run only when requested by an end user. Those snippets are run in one of the bazillion available resources doing nothing at AWS. You pay only for the times that the code snippet is run. You basically have zero limitations on scale, as you're bound by the resources available by AWS... literally you could have millions of people hit your app simultaneously. Each time that lambda is hit, it's like $0.0005 or something like that, plus whatever monthly cost of your storage (S3) is (usually a few bucks per gig per month for storage).
     
  4. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,751
    Joined:
    Feb 14, 2006
    Messages:
    17,417
    Serverless is all the rage, for sure... but it's not a magic bullet. It can work for some things, but is not the solution for others.

    For instance, the financial brokerage I'm building out now is not suitable (we're using Java Spring running in Kubernetes for that), but the Facebook survey bots we're doing for another client are definitely perfect for Serverless.

    There are some nuances around it that take some time and experience to learn, for sure, but it's pretty easy to dig into and learn.
     
  5. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    1
    Joined:
    Oct 19, 2009
    Messages:
    493
    That seems to be a pattern with a lot of programming. It always seems difficult at first but eventually I manage to figure it out.
     
  6. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    1
    Joined:
    Oct 19, 2009
    Messages:
    493
    There was a time when it seemed I would never understand functions.
     
  7. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,751
    Joined:
    Feb 14, 2006
    Messages:
    17,417
    lol

    Totally get it... consider "serverless" to be "function-based programming"
     
  8. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    1
    Joined:
    Oct 19, 2009
    Messages:
    493
    Well, if learning sever-less programming is cheaper, then it's a priority for me. I expect to finish building this database, commit to git hub and go find some tutorials.
     
  9. Binary

    Binary
    Expand Collapse
    Emotionally Jaded

    Reputation:
    193
    Joined:
    Oct 21, 2009
    Messages:
    2,849
    The interesting part about serverless is that it's not much to learn, it's more just a shift in your mind about how the program operates.

    In a lot of programming, you make a bunch of assumptions about variables being available to store data for later retrieval, or writing off little things to disk that you'll need, or making calls to other areas of the program that you expect to be active.

    With serverless, the programming doesn't change, but those assumptions need to be modified. Your function flat-out disappears when it's done with its chore, and each function don't run inside a larger context, it's completely impossible to know what order or time different functions run in, so you need to be very explicit about handling data, calling other functions, etc. I mean, much of this is how you should be developing anyway, but given the number of code chunks I've seen with sleep(10) in them...
     
  10. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    1
    Joined:
    Oct 19, 2009
    Messages:
    493
    So it's all functions? In python, for instance, it only uses the standard library? Do you import any modules?
     
  11. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,751
    Joined:
    Feb 14, 2006
    Messages:
    17,417
    Go take a look at the tutorials by AWS... they do a great job introducing you to the process with some good sample code.
     
  12. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    1
    Joined:
    Oct 19, 2009
    Messages:
    493