[Music] hello everyone my name is dave beckberger i am a senior graph architect on the amazon neptune service team and i'm here today to talk to you a little bit about graph databases and then it's going to go into a little bit of a deep dive in a demo on amazon neptune which is aws's purpose-built graph database offering so let's jump right into it So today when we work with customers we see graphs being used for all types of applications why is this because graphs are very good at modeling relationships that are not necessarily easily
represented or retrieved with other types of databases out there today if we look at this simple graph representation it's pretty easy without me having to tell you any other additional information that you can figure out that alice lives in any town And that she works with bob this is because greg you know this represents how graphs and the graph the graph way of looking at problems is very intuitive to people because they rep it does a very good job of representing the natural way that we think about data and connections in this example you know
we're looking at these and we have what we would consider from a graph perspective a couple of nodes those Nodes representing the entities or the real world objects here in this case being alice bob in any town and we have these these lines or these connections between things which represent the relationships between these real world objects in this case lives in and works with and when we look at this and because of the way that graphs and graph databases store this data it really they really allow you to explore these relationships and patterns And this
type of connected data in ways that other can't uh whether ways of other data stores and data structures can't customers are also very excited about graphs and they're really especially excited about managed graph services since neptune was released in may of 2018 customers have built many types of applications on top of neptune but when we think about it uh when we when we're working with customers we kind of Broadly general generalize excuse me these these applications into a couple of common use cases we see the first common use case we see with neptune is fraud
detection and this is exactly what you think it is we're trying to use graphs to help find the bad guys graphs are uniquely helpful for fraud detection as they really enable us as developers and as users of the system to find the deep links and deep Connections and patterns of connections in the data that really don't aren't easily uh easily found using other sorts of uh systems out there the second use case we we generally see is what we call identity graphs and identity graphs are really based on the concept of you know something like
a user is going to come to your website for multiple different uh different areas maybe they are going to connect to it from their phone and their Work computer and their home computer and their tablet and we really want to be able to connect these these these disparate interactions with the user together in such a way that we can kind of general uh generate a golden record of kind of the the canonical form of that data that a user can actually so we can actually use that to help provide things like personalized recommendations or marketing
ad segmentation things like that Third use case we we often see with customers are one of knowledge graphs or knowledge organizations and this is a really about connecting disparate data silos inside of a company together in such a way that you can really get a holistic view of a specif of of pieces of information and things that are connected to that piece of information let's say you're something like an e-commerce website and you have a Database that contains all of your information about the products you sell and one that contains all this information about your
customers and one that contains all the information about your inventory inside your warehouse maybe you have another one that's shipping and you want to be able to connect all of these together in such a way that you can look at all of the information around a specific product or customer or user something like that And that would kind of fall into what we call a knowledge graph type use case the last one we have is the last common use case we've seen is security graphs and we've recently seen a real uptick in customers interested in
using graphs for security based systems security in general is sort of a graph problem because it's really you know security of for anything being physical or logical or application security or your cloud infrastructure security is Really about layers about multiple different layers of security all being connected together in such a way that you want to be able to look at that to be able to find potential uh paths of of potential um you know malfeasance or paths through the graph and how things may or may not be exposed to the internet for say when they
should or shouldn't be um so that's sort of kind of what us you know one one way we can look at security graphs and This is really kind of a really interesting and fast upgrading or upcoming segment for uh graph based solutions so what are some other common business problems that you think uh that would work with customers when we think about graphs and graph type problems problems really needing those connect highly connected data well as i kind of mentioned already the first one is people come to us saying they need to do Things like
be better at detecting fraud and fraudulent transactions inside their system maybe they want their customers to have a better or more personalized recommendation experience than they're able to provide today there's that knowledge graph use case if we want to connect together those siloed data sources inside our enterprise to really kind of build out a you know an entire An entire platform that contains all of the knowledge inside of our system maybe you have those multiple websites or you have multiple applications and you need to link together disparate customer identities in these systems to kind of
get that canonical or that golden record you know that maybe you have machine learning algorithms and you want to be able to use the connections in your data to Improve those algorithms to give you better sorts of answers these sorts of questions or ones that kind of are if you went out and you you looked online you did some searching around you would probably come back these sorts of questions are really good common business use cases for graph type problems but there's also a wide array of not so easily recognized graph problems ones that when
you you know at first glance may not make Sense or you may not think of them as graph problems but they really do lend themselves very well to being solved using graphs first one example is you know what are the risks in your it infrastructure your supply chain you know any sort of i.t infrastructure or supply chain it tends to get very complicated very quickly there's a lot of you know in the case of a supply chain you have a lot of people that are you know you have a lot of Products each of those
products has its own bill of materials each of the bill of the items in those bill of materials has one or more suppliers and those suppliers have suppliers and those suppliers have suppliers have suppliers and being able to kind of look at the overall risk portfolio of your supply chain or your iq infrastructure is a great use for our graph where did this data come from this is This sort of question of being able to track the lineage or the provenance of data is one that we often talk with data engineering teams about uh these
lends itself very well to a graph because if you think if you can think about it when you're sort of working with you know any sort of data engineering problem it's really about taking data from one source doing some sort of extract transformation and load type process and usually loading it into Something else maybe you're combining or aggregating that data but you probably but when you aggregate that data you still want to be able to track where did this data come from maybe you need to be able to track this to be able to comply
with privacy regulations like cccp or gdpr and you want to be able to track not only where this data is currently but where where all the places it was used intermittent intermediately to be able to you know Clean up those things to be able to understand the accuracy and the efficacy of the data that you're working with why don't your search results relate to the specific question was asking this is a common use case we we see with customers is they have search results but their search results are a little bit lackluster and a little
less clear than they would like them to be so being able to use a graph to be Able to build that you know those sorts of knowledge graphs where you're connecting these data together to be able to give you more relevant and related answers to the types of questions people are asking how does person x have access to information why this is a security another security graph type use case where you really want to be able to you know maybe map out the permissions to that folders and Files have by active directory groups i was
working with one customer where their specific use case was they were you know looking they wanted to specifically look for uh access or people that have acts that had access to certain files and folders through a very very long set of connections because if they had a you know if i was giving direct access to this file or folder it probably means i was Intended to have it but if i had to do that if i had access to this file and folder through multiple sets of groups and permissions maybe it was an unintended consequence
of giving me a permission was giving me access to this this critical business information and they want to be able to kind of track that down and look for that sort of thing and you know things like about your cloud infrastructure your Cloud infrastructure is a very good example of a security graph type use cases being able to look at how different things are used inside of it through a wide array and a very large number of variably connected data if you think about your cloud infrastructure you're going to have things like iam policies which
are connected to roles which are then going to be connected to one of any number of different types of entities be They lambda functions or databases or ec2 instances and you have a very variably connected set of entities that you're trying to look at but when i really kind of sit down if i wanted to kind of boil down graph questions the types of questions that graphs are good at answering really for me it comes down to the where why and how questions you know where are the risks where did the data come from why
don't the search results do Something how about this person how is this role being used things like that and these tend to be good uh graph questions because they have a few things in common first they tend to navigate variably connected structures of data you know especially if you wanted to think about this in terms of looking at your cloud infrastructure the cloud infrastructure as we kind of discussed a minute ago is really it's a Highly variable set of different entities you have you know vpcs you have enis you have iam rules iam policy all
of these are connected together against other ec2 instances or databases and being able to look at that and easily move through that sort of information is an area where graphs tend to excel they also send to excel at questions where you need to filter or compute a result based on the strength weight or quality of a relationship so in the case Of something like a supply chain risk management being able to look at not only the fact that these two things are connected but how important is this supplier to this person what other sorts of
info what other sorts of backup suppliers may they have for specific things to be able to use that to help calculate an overall risk of your supply chain or where the risk or to find the riskiest parts of your supply chain Is an example where using you know where using the the connections in your data is extremely important to be able to get that answer and finally recursing or requiring traversing unknown numbers of connections and this is really an area where graphs really do excel um and this is where you have questions that are a
bit open-ended you know let's take a look at the example of how does person x have access to information why You know they may have been given direct access to this information or they may have this information or access to this information through a wide array of different connections through maybe different active directory groups and things of that nature but you won't know exactly the number of connections or how they're connected at the time you're initially or you're you're originally looking at the query all you know is you want to find out how Two people
or in two entities are related inside this so this is really sort of when i think about graphs and graph type problems these are the sorts of problems i really look for where graphs benefit the you know the the end use case quite significantly and why is this well there's a few challenges around using many other technologies with highly connected data First there they tend to be a little unnatural for querying that data and this tends to lead to an inefficient processing of that sort of information and most other databases out there or other data
technologies out there tend to have a rigid schema that's really inflexible for rapidly changing data that we that most of the types of use cases we've talked about today be they fraud graphs or knowledge graphs or Security graphs or identity graphs really tend to require so let's dive a little bit into that what is it about graphs that actually make them better to handle this sort of highly connected data well the first aspect here is the query languages the query languages that we use with graphs are really optimized to use the connections to move through
through the network of data that you're looking at and this Comes down to the fact that graphs databases and manage graph services are based on graph theory and one of the kind of key pieces of graph theory is this concept of traversing your data or moving from point a to point b so if we what looked at this specific example we're looking at this and it says dave works at amazon um the little gremlin guy is sort of uh representing that's that's the logo for the apache tinker pop gremlin project and that's Representing kind of
where we are in our information today when i write queries and graph query languages as opposed to kind of uh you know when the way you we work with them we'll see an example of this later it really taught you know they really work by moving data from point a to point b so you're i'm moving through my my graph or my network from dave to amazon if we want to contrast this with something like a relational database relational Databases work on relational algebra set set out algebra and they work by combining sets of data
so if we wanted to kind of look at this in the same you know the same thing uh the same example here i would probably have a table called something like person in a table called something like company i would perform a joint on this in order to get the fact that dave is a person at a company um that i work at that company through some Sort of foreign key between those tables and the way you know at its very core kind of the way that that relational databases work as opposed to moving from
point a to point b in a graph you know when i move it from point a to point b i don't necessarily mean unless i explicitly ask for it i don't necessarily maintain the history of everywhere i've been in relational databases as i'm joining these tables Together i'm building a bigger and bigger table in memory in theory in memory that basically is containing all of the information and all of the history of where i've been this is why when you start running large queries that have to traverse or move through a lot of data in
order to get there you know graph databases because i'm moving point a to point b as opposed to building a bigger and bigger in-memory Table or more efficient uh from a memory perspective and a speed perspective we're gonna do it the other aspect there is graph databases are really optimized for processing connected data at the kind of engine level let's you know because graph databases store not just the entities but the connections this really gives them the you know uh the advantage of the fact that the connections that you're working on are Data itself this
means that they're physically saved to disk so when i need to actually retrieve this data in order to know i want to move from point a to point b across the connection i'm really just reading data again i'm reading data off of disk to retrieve that information if we contrast this again with something like a relational database the worksack connection in this example is really metadata it would be represented through something like a Foreign key between those per that person and company table so when i want to find out what company somebody works at i
need to actually calculate that at random time i need to to i need to run that relational algebra to calculate that as opposed to being able to retrieve from disk so when i start needing to process hundreds or thousands or hundreds of thousands or millions or billions of These sorts of relationships the fact that i can retrieve them from this versus calculate them at runtime really does lead to a much more efficient processing of that sort of information and the last kind of uh item i wanted to touch on here is a little bit about
schema flexibility when we're looking at these two uh these two examples up here we see that we have you know these are both representations of family trees With a graph and with with amazon neptune and with most graphs they they tend they're they're they're what's known as a schema-less database i personally not my favorite terminology because if you have data you have schema so i like to think of it more in terms of explicit versus implicit schema so in the case of a graph when i start with its schema less nature or its implicit nature
of schema i can just start writing information to my system i Can write a person and i can start writing a property of a first name or a last name i don't have to declare these ahead of time i don't have to set up tables or keys or constraints around that i can just start writing that information to my system as i as the data that's coming in or the maybe the attributes of that data changes or we add new uh maybe we add a new type of data a new new set of entities to
my graph i can Just start writing those and they will be automatically included into the schema of my graph this provides a lot of flexibility especially as data evolves over time if we want yet again want to compare that and contrast that a little bit to a relational database relational databases have uh explicit schema i need to declare ahead of time that i have an individual and that individual has a first and a last name Um you know you do this in in in pretty much any relational database today and this is very powerful until
you want to start evolving this at scale and speed where you have to you know every time you go and do this you're gonna have to run some sort of um you know schema migration or schema diff process in order to basically bring things up to speed versus being able to just start writing the new entities as They come in there's also a bonus here which is the fact that graphs tend to be easier to understand by new people or non-technical people that aren't familiar maybe with the domain this is because when we look at
these representations you know the representation of the graph is a lot more natural to the way we already are looking at the domain than necessarily looking at some erd diagram that you Have to kind of dissect and put back together in order to figure out how everything's going to be related between them so it's a little bit about graphs and and why graphs are better for some sorts of problems than other technologies but why is it customers come to us why do they want to use a graph database service you know as we kind of
mentioned uh other data traditional database technologies out there really aren't Built to scale when you want to do like deep link querying or deep link analysis across billions of interconnected entities either you know hundreds of thousands millions or billions of interconnected entities for that matter and because of this they really challenge it really challenges those sorts of engines to deliver the low latency required for real-time inspection for of you know things like fraudulent you know Looking for things like fraudulent activity or personalized recommendations or other potential you know potential malicious activities or things like that
self-managed solutions also tend to be complex expensive and inflexible especially if you want to try and optimize them and scale them to the global nature of many of today's applications they require a lot of hardware management provisional provisioning you have to manually scale Up and down these sorts of items and being able to do this in a compliant way as schema changes and evolves over time is very uh you know complex this really leads to a lot of these solutions not being able to evolve at the speed and scale that the landscape of today's data
is changing and this is really why we went and built amazon neptune amazon neptune is a fully managed purpose built graph database Built for the cloud it was released in may of 2018 and since then we have been continuously improving it with new features and functionality based on feedback from customers as i said it's a fully managed service so aws takes care of all the hardware management we manage the os the database server and we uh we manage all of this through uh you know We manage all of this through a couple of ways you
know all it takes is you as a user a few clicks in the management console or a few calls to the api to provision a new neptune cluster and it'll be up and running in a matter of minutes you know one of the core needs of any of these sorts of systems is the ability to scale based on demand so it's critical for it for most businesses to be able to support burst you know traffic that that Fluctuates over over time maybe it's seasonal traffic built to burst on black friday or thanksgiving maybe it's something
uh maybe you only your application gets more traffic in the evening versus the day and being able to dynamically scale is kind of a critical aspect of the way we built neptune from the uh from the get-go and you know the the last aspect here i want to kind of talk about is cost reduction In in many and many other database offerings because they don't scale very linearly you tend to over provision hardware and database servers and v cpus things like that to meet your peak demands because of the scalable nature of of neptune we
really allow you to reduce the cost for you know to reduce the cost overall and add a lot more predictability to your cost by being able to fluctuate Yours your hardware that you're running your database on up and down as demand happens neptune uses a pay-as-you-go model so you're going to only pay for the amount of time your database server is actually running so this helps reduce costs further by not over provisioning overspending and under utilizing this uh as we mentioned neptune at its very core is a purpose bill craft database that's optimized to store
and map Billions of relationships between entities it does this to enable real-time connections with millisecond query response times it does this through support for the three open standard query languages open open specification or open standard query languages those being open cipher gremlin and sparkle does this through being able are by Supporting the two leading graph models out there the first graph model out there is property graph property graph at its very core represents data through the use of nodes representing real world entities edges representing connections between those real world entities and attributes representing properties of
either a node or an edge i think that's kind of a key piece to add in there one of the unique aspects of property graphs is the ability to Associate uh associate properties not only with the entities themselves as you can with many other database technologies but also the ability to associate those properties specifically with the connection between entities so maybe you have a person and maybe they have a product and you have an edge that says maybe they were bought well you can also store you know besides just saying the fact that you know
a bought product b You can also add a properties or metadata to that edge maybe you want to add where that you know how they bought it to or the date they bought that as a property of that connection itself so it's kind of a unique aspect of property graphs if you choose the property graph model in neptune you have the ability to query that data through one of two open open specification query languages one of those being open cipher query language which is a c Provides a sql inspired syntax for customers to use the
second being the apache tinkerpop gremlin query language uh which is a very powerful query language that look well we'll look at both of these here in a little bit but uh look and compare them but gremlin is a very almost stream processing oriented query type language the second graph model that we store in neptune or that you can choose to use in neptune is the resource prescription Framework or rdf you might have heard this referred to as the semantic web construct but rdf represents data inside a graph as a set of triples each of those
triples containing a subject a predicate and an object so if we go back to the earlier example of dave works at amazon if we wanted to look at this with a in an rdf with an rdf data model we would represent that data as the subject would Be dave the object would be worksat and the predicate would be amazon if you choose to use the rdf data model inside neptune we support querying that data using sparkle1.1.1 which is a w3c standard query language for querying rdf data you have thousands of customers are using to neptune
today in production um this is just kind of a really quick short list of some of our neptune Customers across different verticals and different use cases so you know what what is neptune how does neptune work let's take a moment and look under the hood of neptune and how neptune is built what its architecture looks like and then talk a little bit about some of the the the the features and functionality of of neptune So when i think about neptune at the high level i think the architecture when i think about the architecture of neptune
i sort of think of it in these sort of five basic areas the application layer the compute layer the shared storage layer set of service features and service integrations one of the unique aspects of the general architecture of neptune is that we were with with neptune we were able to break out the compute Layer from the shared storage layer it's kind of a very key piece of the architecture this really enables us to provide a lot of these these features that your applications work so let's dive in and take a little bit of look and
take a moment to look at some of these the first layer here we wanted to talk about is that application layer this is where you as the developer really live and work this is where you're building Your social networking application or your fraud detection application maybe it's a knowledge graph or a security graph or one of the other use cases we talked about but this is where you're interacting with it and you do this through any of our three query languages as we mentioned and this basically is a for for property graph we basically have
a set of endpoints exposed both via http or A websocket or bulk connecting connection uh if you're using uh property graphs to be able to write that data to and from the system so you're you're using a set of open source drivers or open uh you know drivers or rest rest and rest api in calls to interact with this system this system uh these applications are going to interact with this compute layer as i mentioned the compute layer in in neptune is Separated out from the storage layer uh in a kind of a unique way
for cloud data or basis cloud-based graph database excuse me and the compute instances are built to allow you to scale dynamic to dynamically scale as your application requires it's a instance based database so you your compute layers are can have up to 16 different instances there's always one writer instance or one primary instance that primary instance can be scaled Anywhere from our smallest being a t3 medium up to an r524xl or recently we also if you have a high memory demands on your application we also recently released support for the x2g family in lines so
you can scale that writer up from with to any of the sizes available within there in a vertical manner for reads most Applicants most graph applications tend to be very read heavy so we allow you to scale out to up to 15 different read replicas in on top of that same data you're storing that data one time each of these read replicas basically will read that same data and those those read replicas allow you to scale yet again uh also vertically from a t3 medium all the way up to r424xl or x2gs as well as
scale horizontally so for From an instance perspective the right instances can scale vertically and the read instances can scale both horizontally and vertically all of this compute instance is separated out from our shared storage layer uh we'll jump into a lot more of the details about this in a few minutes but at a high level this is a shared uh this is a strong a feature of the cloud native aspect of neptune is this shared storage layer that's separated from the Compute layer when you write data into neptune that data is automatically going to be
stored six times twice in each of three availability zones the data scales independent of your compute but it scales automatically for you so when you start at the neptune cluster it'll start with a provision space for 10 gigabytes of data and it will as you add more and more data that data will that provision space will grow Up to 128 terabytes because it's a fully managed service we have a lot of features around automated backup and restore functionality for you and we have this ability we call it the database fast clone which is really about
enabling you as a user to quickly make a copy of your database to maybe do something like try out a new engine version or to try something in your application without having to take Down your production cluster in order to make this happen neptune also comes with a set of service features um that are part of the actual native implementation itself the first one being the ability to bulk load if you're going to bulk load data into neptune we provide an end point inside of the system that allows you to trigger this bulk load from
an s from s3 files uh the s3 files have to be one of a few Sets of specified formats if you're doing property graph there's two different csv formats you can use if you're doing rdf there is three different rdf data formats you can use once your data is formatted into that you trigger this bulk load this bulk load then reads in all of that data optimizes and parallelizes the load to give you the maximum performance for getting that bulk data into your system We also have neptune streams neptune streams is a cdc type functionality
on top of neptune that enables you to basically get a continuous data stream or a continuous stream of data that data changes that are happening inside of your graph this can be used to trigger some sort of down downstream workflows or to be able to pot to basically propagate those changes to Other external systems we also have a status endpoint on the cluster this cluster status endpoint basically tells you just basic information about the health of your cluster we have a query profiling and explaining endpoints that allow you to take sparkle gremlin or open cipher
queries run them through these and get a very detailed look about how the engine is processing that data this allows you to then Go a step further and be able to tune and optimize those queries based on the information being returned to you from those endpoints we also have a a feature that allows you to auto scale read replicas we'll talk a bit about this in a moment but this basically uh at a high level this feature enables you as the user to specify a set of thresholds at which point the your cluster will will
Will scale up and down to match the workload demands based on those thresholds neptune also comes with a few sets of service integrations uh the first service integration is an integration with the aws backup service so if you're an enterprise or you're in your account you use aws backup you can now backup that data or you can now back up your neptune data using that same service we also have a feature called neptune ml But we'll talk a bit about that here in a moment but at a high level what neptune ml is is it's
an integration between neptune and sagemaker to enable customers of the neptune graph database to build and automate the process of building graph neural network-based machine learning models and using those models to run real-time predictions inside of queries we also have an integration with amazon Open search and our integration with amazon open search enables when you you as a user to query open search for full text search type responses or full text search type queries and get those data get that information propagated back into your your query itself as i mentioned kind of one of the
key pieces of the the architecture is this this cloud native storage layer that we Have inside neptune itself this is a piece of really battle-hardened technology in inside amazon where when you write data as i mentioned previously that data is already is automatically written in a highly available and secure manner this data is replicated six times two as i said two times in each of three availability zones it's also continuously backed up to amazon s3 this storage layer itself was Built for 11 9's of durability and it's based on this this this basically 10 gigabyte
segment sizes this 10 gigabyte segment size as i said when you start a cluster you get one ten gigabytes uh one ten gigabyte data size or data segment as you add more and more data to your cluster we automatically provision these these additional data segments for you and this data segment is really the the Unit of repair that this that this system automatically uses to heal itself and to rebalance hot spots inside of the inside of the storage uh layer things like that a quorum system is used for reads and writes so it's very latency
tolerant and as i said as i mentioned this storage volume will automatically grow up to 128 different terabytes excuse me up to 128 terabytes read replicas uh we replicas beyond just Scaling uh late or scaling the number of transactions you can use there's a couple of uh really key aspects about read replicas as i mentioned neptune is an instance-based database and you can run it with as few as a single instance in which case you know that instance will be a writer when you're doing the if you're running in something like a single instance node
With only a single instance excuse me if you have a if there's something that goes on with that writer node for you for some reason that node fails it will automatically be rebooted by the system but that can take several minutes to come up so you during that time you won't be able to serve any traffic inside of your apple or any traffic from your cluster to any sort of applications using it if you set up a read replica that read Replica will basically be used as a failover so if that primary writer node goes
down for some reason that read replica will be promoted to the writer and the writer node will be uh what was the writer node will be restarted as the read replicate itself and this really uh you know this automatic failure detection and things like that will really really minimize the amount of time that your Application won't be able to serve traffic the other reason customers tend to use a lot of read replicas is to scale out the read traffic as i mentioned you can scale out the read traffic across your different um you know up
to 15 different read replicas and balance the right the reply excuse me the read requests and responses based across that uh using the reader endpoint So that sort of kind of uh brings us to what how is how is traffic how do you work with the neptune how do you actually write read and write data to it when you work with neptune you're basically given or i should say when you create a neptune cluster you're giving two different endpoints you're giving a writer end point and a reader endpoint the writer endpoint also referred to as
the cluster endpoint always points to The current writer always points to the point so the current primary instance uh this is the one you would use to do any sort of mutation queries on top of your data if you have read heavy queries as many applications do we also provide you a read endpoint and this read endpoint distributes those requests as they come into different read replicas so if you have three different read replicas this reader Endpoint will round robin uh distribute requests across the i should say this will round robin uh for a specified
period of time will will point to different things so your request will be distributed across your different instances that being said this reader endpoint is is time-based there's no fairness or round-robin guarantees but this is often sufficient for many customers uh one point to note here is if you're using Gremlin with their websockets or using the oc bolt connections those connections once created are sticky so they'll stick to a specific read replica so something to be aware of that you may end up with hot spots in your applications if you're using web sockets or bolt
customers also can build custom request distribution strategies we've seen customers we've had customers that have Built them around fairness or to optimize cash locality um these have to be done at the application level if you want to do this sort of if you want to build these sorts of custom distribution strategies and you also need to be aware of potential failover scenarios and how you are going to handle that another key aspect of the neptune architecture is caching within neptune there's three different types of cache That are used the first being a buffer cache uh
this is always on as soon as you spin up any instance this buffer cache is enabled and it's used to store pages of data of graph data from that shared storage layer in local memory this is really enables much faster queries by being able to pull frequently used data from the local instance memory as opposed to having to go across And fetch that from the actual storage layer itself as i said this is always on it's enabled by default there's nothing you as the user needs to do here one thing we i would recommend is
to monitor there there's a cloud watch metrics called buffer cache hit ratio and you want to really want to make sure that's up in the high you know high 99 you know high 90 percents uh and you can use that by monitoring that Or you can figure that out by monitoring that metric inside cloudwatch the second type of cache we have is an optional cache it's a lookup cache this only works if you're uh this lookup cache i should say is only available if you have r5d instances because what it's doing is it's using the
nvme based ssd data or sorry ssd disks to store property values and literals for use cases where you have to where you're Frequently returning large numbers of these property values to the users this is something you can set up on a per instance basis and will automatically be used uh be used when uh to store that data that data will automatically be populated into those nvme disks as it's being used the second one is the query results cache the query results cache uses the instance memory uh it's also an optional Opt-in cache and it basically
it's exactly what you expect it to be it stores the query results so on a per query basis you can specify that you want to use this query results cache to store that data into uh to cache those query results for a specified amount of time this is really used for cases where you have maybe the same query is highly repeated but the data on the data being returned doesn't change Um the other and probably most common use case we've seen with customers is for pagination if you want to be able to run a query
one time that basically goes out pulls a lot of data orders it and returns the first 10 results and then you want to page the second 10 results in the 310 results um this sort of query results cache is really very helpful there because you will have to you know you run that query one time you can store those cash uh you can cash Those results for for a ttl and the next time you go to pull the second page it'll be in uh very very quick mil you know a few milliseconds sort of response
time to get that back because you're pulling it directly from this query results cache security is also all as as with all databases is a very key aspect of the neptune architecture neptune is built with network isolation it is a pro it is a vpc only database so Any applications or there is no public endpoint so any applications or users that want to do it have to have access inside that vpc in order to talk to neptune data is encrypted with neptune um data is encrypted at rest using aws's kms you can either specify a
specific key or use the default key for your application encryption is also handled in transit through ssl From a user perspective neptune is integrated with iam authentication so you can use iam policies in order to manage access into your neptune uh or into neptune the database any neptune cluster can be iam enabled so every request to that database where we require iam authentication order to make it happen and we we have a a fine-grained set of action-based access controls to to really granularly uh Grant people access to different actions and to different data plane type
actions inside the system as i mentioned uh neptune is a fully uh managed system so we have a variety of automated backup and restore functionalities daily automated backups uh will occur during a window that you can specify in which case uh the full storage volume snapshot is taken the retention period on these automated Backups can be set uh configured by the the customer to be between 1 and 35 days you can also manually create snapshots of your data to back up an entire database instance uh manual snapshots can also be shared across accounts so if
you have a use case where you need to be able to take a snapshot of your data and move it to maybe a prod account or from a prod account to a qa account to a test account things like that you can do that and they can be copied across regions Um you have you know not only do we have the ability to take a snapshot but you can restore those database snapshots uh to a new database instance this allows you to also do things like if you want to change the parameter security groups around
it to test out new settings you can do that and neptune also supports point in time restore so you can restore the database instance to any specific time down to a one second granularity Um not listed here i mentioned i briefly earlier is also a fast clone capability which basically quickly allows you to make an entire clone of your database to be able to test out new and different features another key aspect is the ability to monitor your cluster as it's running neptune integrates with cloudwatch and cloudtrail to monitor to cloud watching cloudtrail services to
basically Log all all the api calls that neptune makes as well as look at different metrics around the database we want to look at the summary of the cpu and memory utilization of all of the instances in our system we can look at things like what is the query throughput what are the success and our error rates of that what is my read and write throughput how much storage is my system using there's also the uh there's an optional Mechanism to enable audit logs audit logs will contain a very granular uh set of information about
every query that's been uh or every query that's being processed by the thing or by the the engine it's going to have information like time stamps what are the servers and client hosts what what message was sent across and that's all going to be stored inside of your cloudwatch logs so it's a little bit about the Architecture let's talk a little bit about some of the new features and functionality that neptune has and then we'll jump into a bit of a deep dive and demo on how that works one of the newest features we have
for neptune is a python integration uh specifically kind of targeted and running some graph analytics and what this is is this is an open source python python integration that allows you to easily read and write Data stored in neptune by removing the undifferentiated heavy work of taking of managing connections and and working with data or getting data to and from the format that graph query languages return to kind of something that's more usable for most uh customers in this case we're using pandas data frames is sort of the lingua franca between these two this library
basically enables you to read and write data from neptune and to Pull that data into pythons where you can use any of the popular open source tool python tools out there to do further analysis so maybe you wanted to run some sort of analytics or algorithm on top of it you could pull data down using this independence data frame and then use a network analysis library like igraph or networkx to run some sort of uh you know small scale analysis on top of your data this also comes with a set Of sample application notebooks on
how it's how you can actually use it the next feature i wanted to highlight here is was released in the spring of 2022 here and that is our support for open cypher so open cypher is a widely adopted open query language for property graphs it provides an intuitive way to work with property graphs by providing developers business analysts or data scientists a Sql inspired syntax that has a familiar familiar structure that you can use to compose queries for graph applications customers this really enables customers that come from a relational background or familiar with sql to
have a very sm a very a smooth on-ramp onto working with graph databases one one of the unique aspects of our uh integra our our support for opencypher is we have built uh this in such a way that you can load your data your Property graph data into neptune once and then you could use open cipher or the gremlin query language on top of that same data this really allows customers that either are migrating from other systems or have data an application already in neptune to start getting uh able to use open cypher very easily
we also also uh neptune also supports uh the open the open cipher bolt protocol this one Basically allows customers that are running current workloads uh to migrate those workloads to neptune with a minimal amount of changes to their application the next feature i wanted to talk about here is neptune ml as i alluded to earlier neptune ml is an integration between amazon neptune and sagemaker to enable graph developers to make prediction our machine learning based predictions on graph data without Having a ton of machine learning expertise it does this by automating a lot of the
choices you would need to make in order to build your machine learning model being which model is the best one to use what training instant sizes i need what what processing instance sizes things like that this is all based on state-of-the-art machine learning uh techniques specifically using gnns or graph neural network based machine Learning techniques and these have been shown in some some external studies to be up to 15 more accurate than some other uh machine learning based models uh machine learning based paradigms out there neptune ml is really built to scale to the large
data sets that we have our applica our customers of neptune using today because you know when you're working with knowledge graphs or fraud detection or product recommendations You're talking about extremely large amounts of entities you're working at maybe up to billions of relationships neptune ml went ga a little about a year ago and recently we have added support for custom models which allows uh customers that have expertise already in gnns to build their own custom model implementations of python but still be able to use that with the rest of the neptune ml framework And we
added support for sparkle so now you can whether you're using property graph or you're using rdf you can use neptune ml to enable machine learning based predictions on that graph data we also recently announced fine grain access control from for data plane actions uh this is really about allowing the customers to specify at a very granular level which sort of actions a specific iam role can take so this Allows you to specify roles that are maybe only have access to read or only have access to write or only have access to trigger bulk loads things
of that nature this really allows for kind of least privileged access allows you to set up least privileged access for applications that are using neptune to give them only the specific permissions that they need this is now the default when you turn on iam authentication as of the 1.2.0.0 release And it really allows you to create those separate policies to any data plane api another feature we recently added to simplify some of the operational headaches is the auto scaling read replicas as we talked about earlier neptune is an instance based database it allows you to
scale read replicas up to 15 of them and auto scaling read replicas allows you to specify a minimum and a maximum capacity for that a scaling threshold based on Some of the cloud watch metrics and then it will automate the scaling activities as your workload demands so as your workload ramps up it will scale out additional read replicas as your workload demand uh eases it will scale those back so it really helps automate someone it helps automate the process of doing that as well as provide you some cost optimization by not having to run additional
read replicas when they're Not needed another operational simplicity that feature that we recently released is one i'm very excited about and that's neptune global databases neptune global databases allows you to deploy neptune clusters across multiple aws regions for fast cross region disaster recovery or low latency queries the two reasons uh you know at its core this allows neptune global databases allows you to set up one primary cluster in up to five Different secondary clusters that are read only in different aws regions um two main reasons which we've talked with customers are interested in this feature
the first is disaster recovery in a scenario where uh you know you may have a regional outage customers want to be able to easily have their data actually easily maintain business continuity of their data When regions out by failing over to another region the second common use case we have uh talked with customers about is for global applications have been able to co-locate your data closer to where your uh user is to now enable lower latency reads as part of a kind of a global data distribution strategy this is as i mentioned this is this
is a managed feature so there's you know it'll also would allow for things like Fast cross region migrations uh and it's got a low replica lag between these these regions so the data is going to automatically be written into the primary region and then that will be automatically replicated out with a low latency to the other aws regions that you have clusters configured for beyond just uh you know feature or features new features and optimizations for operations we're actually have several new features related to cost Optimization for users of their system first being our support
for graviton 2. graviton 2 in our testing has shown to improve query latency and lower the cost compared to some x86 instance sizes so not only do you get faster queries you get to pay less for them so that's always a real benefit to customers and this is partially uh there's a lot of reasons behind this but part of this is also we inherit some of the benefits of The aws nitrate system for private networking and fast uh local storage as of today we support the t4g series uh for low or for low cost development
and test type workloads we also support the r6 g-sys series and recently we added support for the x2 g series for any sorts of uh excuse me for any sorts of uh use cases where being able to have a lot of memory and a lot of buffer cache is very is beneficial As of april we also offer now offer a free trial offer for neptune this free trial offer does not limit the features of neptunes this means if you're in an organization that has not created a neptune cluster you can get started using this uh
are trying out neptune for free and this means you can use any of our three query or any other two graph models or three query languages to do it for eligible customers you're going to get up to 750 Hours of t3 medium instances 10 million ios a gigabyte of storage a gigabyte of backup and this is going to be free for 30 days with no restrictions after that 30 days it's a pay it's going to reserve report revert to a pay-as-you-go model so you're only going to pay for the resources you consumed no up-front licensing
costs so now that we're uh you know kind of walk through a bit about what net what graphs Are what is amazon neptune some of the features of it let's do a deep dive and demo and take a look about how you can set up a neptune cluster and then why you might want to use this with some for some of the common use cases we discussed so what we're looking at here is we're looking at the neptune console what i'm going to walk through is you know if you're coming in here you're new to
Neptune and you want to create a database let's take a look at what you need to do in order to make that happen we're going to start here we're going to click on create database it's going to provide you a list of options you can specify that the version that you want to have of neptune especially if you're testing it out i almost always recommend you try out the newest version of the system you can specify a specific identifier for This in this case it defaults to a name of database one you also specify the
template and the template uh here basically lets you choose or specifies the set of instance sizes and some basic configuration parameters that you have um when you select the dev and test instance you it provides you access to the t3 medium burstable class of instances these are really only good for development and testing type scenarios so if you want to Create a production type cluster you want to select the production template which is what i'm going to do here um from there i can select the instant sizes i have as you can see we have
quite a few instant sizes to choose from i'm just going to leave it at the default one right now of r6g extra large you can also uh in a production when you select the production template you also Get the option to create a read replica and then different availabilities right out of the box out of the box you can specify if you have very specific vpcs you want it in you can specify that sort of things we also have the ability to create a notebook i didn't mention this until now but one of the features
that comes with neptune is this construct of a neptune notebook a neptune notebook is a free open source package we'll see it here in just a Moment and it runs on top of the jupiter web-based ide and provides the ability to run things uh you know to be able to interact with your cluster as sort of the ide for neptune um so we can automatically create one here uh i already have a few a database up but uh so i'm not going to do it here but if i clicked create database at this point what
would go through is it would go in it would provision out that storage it would provision out the Instances you had and it would spin all of this up and within a few minutes you would end up with a database that shows up here it would show up as available in this case as you can see i have two databases once uh sorry two clusters excuse me one called air routes one's called altimeter uh they both have a single writer instance and they're both currently available so let's let's jump in to one of these and
start taking a look at what it looks Like to actually work and interact with with neptune as i mentioned uh we're going to be using what is known as the neptune notebooks that this is a jupiter notebook so this is a free open source package if i come in here to notebooks you can see i have one notebook running i can open it from there um This ide is exactly uh this is the the ide we provide into neptune it's uh you can run this either as a hosted infrastructure piece of infrastructure or not as
you can see when i click on this it pops up a hosted uh info a hosted jupyter notebook this is hosted as part of sagemaker notebooks you can either use this open source neptune notebooks package through these hosted instances as i am here or if you Have your own jupyter server you can run and install this and as long as you have connectivity into the as long as you have connectivity into your neptune uh the vpc where neptune exists you'll be able to run these sorts of things um when we come in here we'll see
there's a set of notebooks in here automatically we have ones around a few getting started notebooks that Really go into talking about what it you know what is a little bit about neptune notebooks how you can use that to access the graphs a few different examples we have some that uh we have some example notebooks that go through the different types of visualizations that you can actually uh build and run with neptune notebooks uh we'll see those here in a moment we also have some sample applications Specifically around fraud graphs knowledge graphs and identity graphs
that enable you to be able to go in and give you a set of predefined uh actually gives a set of predefined data that you can load into your cluster as well as a set of predefined queries that you can start to see how you might go about building one of these sorts of use case applications and we have a set on machine learning if you're interested in using neptune ml You can come in here and look at the uh this xero4 machine learning and this will give you a very detailed walkthrough of the different
features and functionality of that uh that feature of neptune for this example i'm going to jump into this notebook that i have called oc gremlin examples and let's take a little bit of a look at what some of the things we can do here um you know As i mentioned we have that query uh we have that status endpoint on on our cluster with neptune one of the things i should say with neptune notebooks it it provides a set of what are known in jupiter as magics anything that starts with this percent sign is one
of those is a magic and it basically allows you to do a specific feature and functional a piece of functionality here in this case this status one is going out querying that endpoint that status Endpoint and bringing back the data you can see the different types of information here you can see when my cluster was started what's the role of it what's the engine version i'm working on what versions of gremlin sparkle and opencypher supported any of the lap mode or beta features i'm looking at here any of the other features such as the result
cache that i may have enabled Beyond that we can also uh do things in our cluster like bulk load data so if you have data stored in an s3 bucket you can use neptune notebooks to kind of give you a a graphical walkthrough of being able to set up that the call that basically triggers that sort of thing i'm not going to do that here we also have a fast reset functionality so if you're in this stage of building your application where you need to be Able to clear out your database quickly you can use
the the fast reset or in this case you know through the db reset widget to be able to basically wipe all the data out of your cluster and start over from scratch i'm not going to do that here um because i have some data loaded in here uh the other the other command that's very useful here is as i mentioned we have some seed data sets some some data sets for very Specific types of use cases uh that we provide out to the user uh through this notebook that you can use to to get started
here and what we're going to use here is i've already loaded this data but one of these is a set of air house data so this is airports and flights between airports and we're going to use that to kind of walk through a little bit about what going and querying these graphs sort of look like So in this case we're working we're going to be working with property graphs and i'm going to be showing kind of talking a little bit about some of the basics of graph query languages and how you can use those to
do things the first one we're looking at here is opencypher uh opencypher is as we mentioned has a sql inspired syntax so if you're looking at this you can probably right away even without me telling you anything Probably have a reasonably good idea of what's going on here uh in this case uh site opencypher is based on kind of a pattern matching syntax uh anywhere you see the parentheses that represents a node uh we will see it here in a minute but anywhere that you see uh kind of an arrow and a line represents connections
and you can use this to build more complex types of queries in this case it's kind of the most basic query you can look for i'm just going to Be looking i want to match any nodes that node is going to be labeled n and i want to match any nodes where the code of the airport is anc for anchorage airport i can come in here i can run this uh you'll see it'll give me back basically the information i had i can view this in the json format that's natively returned from neptune i can
also view this as a graph This is one of kind of the key features of of neptune notebooks is this ability to come in here and make this bigger we can come in here and look at this thing in this case it's not as interesting as it could uh would be in some other cases because it's just a single entity but i can come in here i can also look at all of the properties that were returned as associated here so we can see these are the uh you know this is that property Graph model
where you're looking at nodes the node in this case being an airport as well as the attributes associated with the properties associated with it um the other uh the other live query language we support for property graphs is gremlin uh as i mentioned uh as a compared to the sql inspired syntax of uh opencypher gremlin is more of a stream Processing type language where data is pulled in from kind of one side of a step some aspect or pro or process is done on it and it sets on to the next one so in this
case um i'm saying uh g is just a convention for kind of starting with a graph in this case you can sort of read this query as starting with the graph i want to find all of my vertices and then i want to filter this down to Only having ones where the code for the property code matches asc anc excuse me for the anchorage airport and then element map basically says bring me back all of the properties associated with that um if i go in and i run this um we'll see i get back a
very similar uh i get back the similar set of information uh the formatting is different between them um but i can also view this one as a graph as well um so this is the sort of pieces And functionality there um let's kind of you know that's the very basic uh way to use both the neptune notebooks as well as oc let's take a little bit uh you know a little bit of a more interesting look at some of the uh more complex things let's start using some of that pattern-based syntax so in this case
i not only am i starting with at the location of the anchorage airport i have added this additional functionality with these dashes and These squares to basically say i want to now traverse out from this anchorage airport i want to traverse out any edges that are specified as a route to a destination airport so basically i want to find anywhere i can fly to or from anchorage i go and i run this we see that comes back very quickly and i'm able to graph this out in such a way that i can see of Basically
i i can see all of the airports that are connected into the anchorage airport itself um if i wanted yet again i could come in here and start going through and looking at different uh properties associated with these these items as well as properties associated with the edges as i mentioned earlier edges can have properties inside of the edges can have attributes representing Properties of those edges in this case i have this property called dist which represents the distance that i need to fly in order to get there this is very powerful to be able
to create these sorts of patterns that work to filter very efficiently and effectively i'm not going to go through all of the examples here with gremlin uh exactly what's going on but these are you know i'm able to run the same sort of queries In both opencypher gremlin get back very you know get back answers that are the same sort of answers um i'm going to jump next into when uh one of the things didn't mention about property graphs is when i'm running uh when i'm creating relationships inside of a property graph those relationships have
directions associated with them there's a directionality aspect to it You have you know this relationship is going from some place to some place you can represent that inside of your graph query languages uh in the case of opencypher you use you represent this using arrowheads kind of pointing in the direction that you're looking for um so in this case as opposed to finding all of the area it's supposed to find all of the airports that i could fly to or from anchorage from uh i am now only Finding those places i can fly from anchorage
to so anchorage is going to be my start location and these are the airports i can fly to we can represent the same thing inside of gremlin um using a different set of steps that specifies the directionality here but the key piece to know here is you know edges inside graphs have directions and you can use that directionality as a filtering criteria You can sort of think about this if you want to think about it from the the construct of a like something like a social network if you're on twitter you might follow somebody but
that person may not follow you back something like that so using those that directionality as an aspect of your data modeling is kind of a really strong feature of of graph databases um And you can keep extending this out you can extend this out in this case i'm not just finding everywhere i can fly to but i'm finding everywhere that i can fly to from anchorage that i can then fly to austin so basically i can want to find you know in this case two hops i'm specifying the exact number of hops so if you
want to think yet again in a social network sort of segments this is like the friends of my Friends sort of idea but when it really comes down to it these you know even these sorts of queries are ones that other databases can probably handle you can probably write a query inside of sql uh you've probably written similar queries where you'll be able to join tables together multiple times really the power of graph query language starts to happen when you have these variable length queries And these are represented naturally inside both gremlin oh and the
open site for query language has really native constructs of the language to support this sort of thing so in this case i want to you know in this case my query is finding all of the flights from anchorage to sydney that are within four hops so this is where this um you know this variable length query syntax starts in in the case of opencypher you do this using this star 1.4 in this example and it's going to find me the i i put a limit on this because otherwise it's going to return quite a lot
of data but this is going to you know you can start to see how you can use this to very quickly and efficiently find these sorts of variable length connections that in ways that if you were going to do this in other technologies you'd have to write like Recursive functions or some sort of cte common table expression in order to be able to return it as i mentioned this is supported both natively in opencypher uh or inside of the gremlin query language here so that's a little bit of of kind of the the basics of
graph query languages how you sort of write these let's let's jump right in and maybe take a moment to actually look at what this looks like For a real use case and in this case we're going to look at security graphs we're going to look at a security graph use case and why you might want to use a graph to do this and we're going to do this by graphing our aws resources you know we're all sitting here working on top of aws let's take a look at what our resources look like and what it
looks like as a craft you know your your resources in aws kind of are Naturally lend themselves to graph representations because there's a lot of connections between these items and these connections are really in many cases the keys things that you want to look at let's start by just taking a look let's see if we have any policies out there that are potentially insecure maybe these are anywhere where you have an administrator the administrator access policy or you have created any policies where You have a star is part of the the document text we can
sit there and basically take a look very quickly and see that we have two of these policies out there we have an administrator access policy as does everybody also somebody has created this this policy called um opens3 not sure why somebody decided that we should you know create an open s3 policy but we should probably investigate that a bit further And see exactly what how that's being used you know the first part here is let's let's take a roll let's take a moment and see if there are any roles using this because you might have
a policy but if it's not being used may not be a big deal um if we take a look at this we can see that we have you know a few different uh roles be using this we have this role called altimeter that's using both this open s3 policy as well as the administrator policy so We're going to probably want to take a moment and dive a little bit more a little bit more deep a little deeper into some of these uh how these are being used to see if we have any potential security issues
so you know let's let's jump to the next step and basically say okay we have these roles we have these access what resources inside my system are actually using it so what we can see Is that there's an ec2 instance that's basic that is using this opens three role we can also come in here and see that there's another ec2 instance that's using this i need admin access role probably you know do they really need admin access i don't know we probably need to do a bit further investigation into that as well and take a
look at what's going on there so what all connects to these resources as We can see we can start to we're starting to build out kind of a a much uh more robust query to basically find everything all these policies now we're finding roles now we're looking at all of the things that are connected to this and we can kind of see that we're really building upon this query in an iterative nature um and we're using that to start to see more and more information data about our system Based on the connections and the connectivity
of these systems we can start to see there's a lot of things connected to this there's a lot of different vpns and internet gateways uh looks like there's a database uh connected to this over here so this fact that we have these very permissive policies is something we probably want to take a look at uh from a security perspective inside of our own system here Um you can then take this and build it out further and further in this uh and as you're doing this you can also filter it down to being able to only
show things that are more interesting uh to the specific question trying to answer you know for example i don't necessarily need to look at the vpcs associated with this because i'm really more interested in what ec2 instances are using these very Permissive policies and roles inside of my aws architecture um and then finally i want to be able to you know potentially look at potential security of threat vectors associated with this i want to see not just that these ec2 our instances are using these rules but are any of these actually exposed to the internet
and in this case as we can kind Of see both of these are actually exposed to the internet as well so we would definitely want to go look at locking these sorts of things down to be able to find you know to be able to make sure that we're securing our infrastructure appropriately so this is just kind of a quick use case a quick example of how you might want to use uh you know a real world type of use case for a security Graph on top of the amazon neptune graph database if you're interested
in trying out that demo yourself what you uh we have a couple of resources for you to start with the tool that i use to map out all of my aws infrastructure is an open source project from tableau called uh called altimeter excuse me in it under the cover what it does is it goes out uh with sufficient permissions It goes and reads the different configurations of your aws resources and generates a graph which can be stored in amazon neptune if you're interested in how to do this uh the second link i have there actually
is a blog post uh on how to exactly do that on top of neptune how to install it correctly how to make it uh and then how to work it with it inside of neptune so as we're kind of wrapping up here i Wanted to give you a few additional resources on how you can kind of get started uh with using neptune um first and and the first link you see up here is the link to the neptune notebooks or the graph notebook project the one that i used for this demo that provides that ide
type application in or the ide uh interface for neptune if you're interested in how you can use neptune with some reference architectures are for it you can follow The second link here we also have a set of full stack or a set of applications from full stack applications to partial applications sample applications that the third link here will show and lastly if you're just interested in how other customers are using this what blogs we have code samples videos you can use uh the last link here will take you to that those areas specifically uh for
amazon neptune Thank you for uh listening to me today uh once again my name is dave beckberger and you can find me on twitter at bachbd thank you you