

We’ll use this API to load our station data into DynamoDB and, in turn, ElastiCache by using a DynamoDB Stream. Like many other bike share programs, Divvy exposes a complete listing and current availability by using a public API. The version of the redis library used in this sample (version 2.6.5) doesn’t yet directly support Redis GEO commands, so here we make use the generic send_command function.

Here, we will demonstrate an integration with Redis using a popular open source library for Node.js ( redis). When working with ElastiCache, you can use familiar libraries to connect to and interact with your Redis and Memcached clusters.
#The geodist database how to#
The README provides detailed instruction on how to deploy the application in your own environment, making use of AWS CloudFormation.
#The geodist database code#
It will also create an ElastiCache cluster, DynamoDB table (our system of record), and DynamoDB Stream as well as a Lambda function to process that stream ( StreamProcessorFunction).Ĭomplete sample code for our example is available at. Reviewing the architecture above, our SAM template will create two public-facing API actions, one to prime our data store ( SetupStationFunction) and one to find nearby stations ( ListStationsFunctions). SAM also eases deployment using specialized tasks available in the AWS CLI. SAM extends AWS CloudFormation to simplify deployment of serverless functionality, including AWS Lambda and Amazon API Gateway. We’ll use the AWS Serverless Application Model (SAM) to manage and deploy our AWS resources, including supporting storage (DynamoDB and ElastiCache). In this post, we will explore the associated backend services, as shown in the following image. Our app will enable users to search for nearby Divvy bike share locations in Chicago. There are a variety of application patterns that can be used to leverage ElastiCache with your data, some of which will be discussed in this post.īike sharing programs are becoming increasingly popular in major cities throughout the world. When used in conjunction with any database including Amazon RDS or Amazon DynamoDB, ElastiCache can alleviate the pressure associated with heavy request loads, increase overall application performance and reduce costs associated with scaling for throughput on other databases.Īs an AWS managed service, Amazon ElastiCache also removes the undifferentiated heavy lifting involved with administrating Redis. You can use Amazon ElastiCache to accelerate your high volume application workloads by caching your data in-memory providing sub-millisecond data retrieval performance. You can easily extend the app to other cities or to use other geo datasets. This post explores using these capabilities to build an app that locates nearby bike share stations in Chicago. Among the open source in-memory engines available to you for use with ElastiCache is Redis, which added powerful geospatial capabilities in version 3.2. This approach might seem more complicated than the Solr approach, and if you are sticking to searches in lat/lon of the give me all images matching this attribute within distance d of this point then SOLR will certainly do what you want, but if you want to consider more advanced spatial functionality in the future, and take advantage of other database features, you might want to consider the spatial database approach.Amazon ElastiCache makes it easy to deploy and manage a highly available and scalable in-memory data store in the cloud. You can so similar things with Oracle and SQL Server (and to a lesser extent with MySQL). select * from images where ST_DWithin( point, st_setsrid(st_makepoint(2.1, 41.38), 4326), 5) It also has good full-text search capabilities for the attribute part. Postgres/GIS uses a R-tree index for spatial indexing, which allows for very fast and efficient searches of this nature. As an example from Postgres/Postgis you could use the function, which allows you to search for everything within a distance of some point. Note there is also the geodist function, which allows you to sort by distance, if you wanted to highlight closer things.Īnother approach you could use would be to use a spatial database and store the location data as a point field. You could substitute your attribute for how far away an image can be seen for the d parameter. Where q would be the non-geospatial part of the search, sfield is your location field, pt is the point (which has to be in lat/lon, and is Barcelona in the above example) and d is the distance field. The Solr documentation has an example of using the distance filter that allows you to find anything with distance d of some point, eg, &q=*:*&fq=&pt=41.38,2.18&d=5 Solr has geospatial search capabilities (which have been considerably enhanced recently via the Java Topology Suite library).
