Jason Structures, Twi- Leo, Jeff discussed on Software Engineering Daily
API gateway and you're just receiving Jason. John David Structure in is your input doing your thing and sending Jason as output in expecting that container the spend down right but from what we know about the scale to wonder skill to whatever you call it minimal provisioning or what is it called for lambda. I think it's capacity. Yeah so do we know anything about what the the medium of runtime is a container or is it like it is like a far gate instance or are we. Just don't know I I I don't know okay the rule we might have raw goat's right. Okay and then so does that. Give the degree of reliability. You need to be hyper responsive or are you saying that. Api Gateway is your highly reliable fronting combination of API gateway plus the layer behind API gateway. That's responding to those events in queueing them up right in. The lambda stuff takes over once. Things have been queued. And that's what then sees the process through to the final ultimate delivery to the downstream partner provider. And what do you use for the queuing us? Okay all right so hits. Api Gateway then gets cute on us and that cueing action triggers lambda. And I guess do you have like different lampposts for the different providers whether it's like a Lambda Lambda dedicated to send grid? Or how does that work? That's right yeah so you can. You can bind lambda functions to Q. Q.'s so that as you pop messages onto that cue. The lambda can just rip that off and so when our land will function runs it's basically effectively being passed in that message by the infrastructure processes that message potentially puts it on another queue depending on what step of the process. It's an or that's responsible for delivering to one of our integrations. So yes we so we have about twenty different integrations with different partners like slack and send grit in Tokyo and each of those are their own land function pulling off of Accu- provisioning a pulling the configuration data from that customers installation. So what are Your Api keys for Toledo right and then making that outbound? Call to Twi- Leo. Then we have to receive that response and deal intelligently with it so what happens if the tweet is down. Well depending on the scenario we might either. Req- that for later delivery or Req- that as a reroute to a different channel. So we take an example like let's say are ordered a grocery delivery and it's coming to my apartment and the grocery delivery service uses courier and the system has been configured such that since the grocery delivery is on. Its Way to my apartment. There's going to be a text message that needs to be sent to me. And so give me a sense of how that message is getting routed or first of all how that triggering you know how the grocery delivery service is having that triggered on their back in that there needs to be a text message sent or there needs to be a notification sent to this person and courier abstracts away what the notification is going to be whether it's going to text message or it's going to be an inapt notification or it's going to be an email the API of the grocery delivery service says okay notification needs to be sent to Jeff that notification hits your API. What happens next so the grocery delivery service calls our API to pass him an event ide- right and they might call that delivery notification might be Ryan without event which would be one of those ten to one hundred notification types. They have exactly they'd pass in Jeff's recipient. Id this typically be the user ID from their authentication system right so whether using zero or something else. They've got to use their I. D FOR JEFF. They pass that over to career and then they pass over. Whatever data is relevant to the so might be a list of the items that are being delivered the final price and maybe a estimated delivery time right so they passed that over just as Jason data structure to courier so now courier accused that up so we receive that we cue that up. The next up the happens is a career. Lambda function picks at a Q- pulls data about that customer. That tenant as what we would call it internally. We look at configuration for that tenant we look at configuration data for that template that matches that event. Actually have a whole event mapping systems. You can start to push events to career without notifications existing on the other side and then you can later come in at an invitation. Say whenever that event comes in the next time. I want you to send this notification of these channels so we have to look up the mapping to figure out okay for that delivery confirmation event which notification or notifications are going to map to it. We pull in the configuration and templates for that notification. That's all part of what we prepare stuff. We kind of bundle this up into a package that we then Req- the next step is what we call a route package. It calculates through looking at the user's profile data which we actually also pulled in the prior. Stop looking through the configuration. What what channels have been configured for this notification which of those channels are still active. We have the API keys and all the data we need and then it kind of builds out here are the possible destinations and go through the kind of privatization and rules. Engine to figure out. Which of those are we going to select? There are ways to configure. Curtis say to send multiple so we have to figure that out as well and then next up is basic queue that up for a rendering pass which is okay. We've decided based on this process. This notification is going to be delivered over SMS. So we basically boil down in that routing stuff to figure out okay it's GONNA go rest mass and so now it passes a message off onto a cue for this mess including the template that needs to be rendered and the data that needs popular that template we then have a per provider rendering engine. That can you know if we think about. What is the format for vacation? Let's html was format for an SMS notification let's Plain Tex was the format for slack notification. What slacks proprietary Jason Format called Microsoft teams has a proprietary Jason Format Etcetera? We have renderers and serialize for all of these providers so we take that same template data in render it for that specific channel. Then pass it off to basically to call downstream writer in this case. Let's say Twi- Leo for SMS assuming that the responds and says it was success. Then we're done and we can mark that as a success and wait for the engagement event to kind of update that record later if it fails then we kind of go back a few steps and we go back to the routing process to figure out whether we want to go back to Tokyo again or whether we want to go to a different channel. Okay cool so that's a pretty detailed explanation. You've given just to revisit the architecture you're fully server less architecture you've got to decide what data services to us so. I'm curious if you've got you know I'm sure stuff that you need to access really quickly. So maybe you're using Alaska cash or I mean maybe just walk me through the data services that you're using on wwl side. Yeah so you've probably got the impression already that we're pretty heavily. Invested in aws and features that accurate. That is very accurate. So Lynn or pretty all in. Yeah I know. A lot of companies are trying to build to be agnostic to the underlying hosting infrastructure. I think that that will be seen in a few years as the same kind of messed up. We made in the ninety S. Orum's we're trying to abstract away. Which database layer that. We were talking to what that generally meant is that you spent a lot of time building an inferior way to use the power and capabilities of the technology. And then you never actually switched anyway right. I think we'll see the same thing happening. With hosting infrastructure we can take a benefit and advantage of a lot of the key capabilities. And frankly you could for GP or your if you actually just commit an build for the infrastructure. So let's let's table that for. I'll go deeper there so on the persistence. Layer for that delivery pipeline. One of our goals is that we have basic maximum number of queries that were willing to call per function. Because again we're trying to reduce the latency throughout in every single one of those call is queries needs to be key value up. They can never actually do a scam. The can never do a multi-record query. We have to know exactly which key to pick up and we only do up to three calls per functioned peopling minimal. We've dynamo as the persistence engine. For All of those key value look ups. The data that we right into Dynamo is also streamed over to an elastic search cluster. We use that in our logging. Ui for actually quarrying and fasting data but all of the kind of run time things that happen when you call Api between then and when we actually deliver that message to Twi- Leo Justin Grid all of that is key value look ups and Dynamo and the latency is not an issue. I think we did a little demo before the past and when I click on send in our little. Api EDITOR LEASE INSOMNIA. But it's like postman. If we remember the slack use case the slack notification showed up before I was actually able to tab over to my slack. Claro true why is it so fast I like I mean I assume if you compare like Dynamo visit maybe gonNA sound like a naive question? Be Compared Dynamo. Db to read this. You know I would think that you would need something you know some kind of memory. Data access layer in order to get the kind of latency. You would need out of notification infrastructure. I think as long as you're restricting yourself to just pure key value ups you know. It's it's fundamentally Hash table and if you're just indexing directly into the exact record in the hash table database servers are really good at doing that right and so that is all you know in some ways we are using dynamo as effectively erectus infrastructure right. Because we're not writing queries into the underlying Jason Structures within these records. It's all key value. Look and we benefit so could we use Lhasa cash? Could we use the renaissance literature we could but by using dynamo we can do things like dynamically spin up lambda functions when certain rows are updated and we use that for example to than stream creation record creation and record changes over to elastic search? Right so again. By committing to that infrastructure able to benefit and tied in to all the other services and reduce our operational complexity in our engineering costs and so what using elastic search for elastic search is inquiries so anything. That's not a key value up where we are potentially returning multiple results. Those hit elastic search. Those are generally only happening within the user experience when you log in as a developer or administrator to see the list of templates and then listen notifications also see the logs so every time you send notification through courier we track that as a log you can log into cur can see those logs you can click into that law you can see. What did you send the courier? What'd career load for the profile? Why did career route it to a specific channel? What did that channel partner send back? So let's say you're called Twilla was failing currier would show that to you. In the dashboard you click into those notifications. And then you could see that. Twila responded back and said your API key is invalid so maybe somebody rotated the key and forgot to update the carrier installation or something else has happened. You'd be able to see that in those logs because we'd capture what Twi- Leo and what's in Grid and slack with a returning to you.