Service Oriented Architecture (Tue Feb 15, lect 9) | previous | next | slides |

We start going in to more complicated core architectures

Logistics

  • Questions to ask in Slack
    • Were you successful with NT Storage?
    • Did you use a new gem? Which one?
    • What problem did you hit, and were you able to overcome it?
    • What is your heroku url?
  • Let’s take a look at this active_record example: sinatra_activerecord_sample

Service Oriented Architectures

  • Divide a system into “services” that communicate with each other
  • Services can be implemented by one or multiple “servers”
  • If more than one, then requests get sent to them based on some algorithm

How does this communication work?

  • Almost always using tcp/ip (which requires an IP address)
  • Often http but not always (e.g. database servers typically don’t use http)
  • Each service has a way that it expects to be called
  • This is called its “API”

APIs

  • Almost always there’s a software library that encapsulates the API
  • This is often referred to as the “binding” for that API in a certain programming language
  • I.e. “Is there a python binding for MongoDB?”
  • The client uses the binding to call the server
  • Key parameter is the ip address or dns name of the server

Services

  • A computer (a host, a vm, a droplet, a dyno) responds to a request. Call that a “server”
  • You may have more than one of the same kind of server together responding to requests of that type
  • These are not public IP addresses. They are not accessible outside of the internal infrastructure
  • Still there are IP addresses and often dns names

Clients

  • How does the client know what dns name or ip address to use?
  • If there’s only one instance ever, it could be put right into the code (MongoDb.open_database(“ourdata”, “12.32.33.44”)
  • Even that is dangerous. If you need to upgrade or otherwise change your network organized, the ip might change
  • Github or other public repos
  • Be careful: never put any secret keys from AWS, Twitter, or anyone else in your code
  • Hackers constantly scan these public repos and find the keys and turn your account into a Bitcoin Mining Operation
  • Also don’t include IP addresses
  • Many approaches to dealing with this
  • Simplest is Environment Variables

Choosing Software Engineering and technologies

  • Everything is constantly changing
  • Improved sometimes, made worse sometimes
  • New alternatives are invented
  • Totally new approaches are invented
  • Key responsibility is to know the options
  • Understand the tradeoffs
  • Decide what is worth learning and what is just cargo culting
  • Learn how to critically analyze your needs and the tradeoffs.

Technology Grid

SubjectDefaultAlternativesComments
ORMActiveRecordSequel, MongoidOf the others, I think Sequel is the most interesting alternative. If you are using NoSQL then you would be required to use a different ORM.
DatabasePostgresAmazon DynamoDB, MongoDB, Relational databases are the obvious choice. But could you get better performance, scalability or programmer happiness from other choices?
Cloud DeploymentHerokuDigital Ocean, AWS BeanStalkHeroku is the easiest to use. But Beanstalk is a little more large scale for the same price, and Digital Ocean is somewhere in the middle
Continuous Testing and DeploymentHerokuCodeShip, Github ActionsThere are lots of choices and many of them are pretty similar. The one new entrant that is pretty interesting is Github actions
Logging and Error TrackingRails Built InDataDog, Rollbar, Lograge, Sentry, AirbrakeComplex systems rely heavily on log and error tracking, for troubleshooting, notification, and billing.
Background ProcessingSideKiqSuckerPunch, Delayed::JobThere are options and tradeoffs. Here's a good article: https://scoutapp.com/blog/which-ruby-background-job-framework-is-right-for-you also: https://blog.appsignal.com/2022/02/15/delayed-job-vs-sidekiq-which-is-better.html?utm_source=ruby-magic&utm_medium=email&utm_campaign=rss-email&utm_content=button
CachingRedisCachedDThese are the two main ones
UIHTMLBootstream, React, ElmI recommend keeping it simple with just HTML plus some css library like Bootstrap or others
Web FrameworkSinatraPadrino, Hanami, Rails, many moreGood article: https://naturaily.com/blog/8-frameworks-ruby-not-rails

Thank you. Questions?  (random Image from picsum.photos)