Microservices Architecture Django [closed] - django

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 days ago.
Improve this question
I am new to microservices architecture. I have a microservice (A) responsible for registering and logging in users. And, I have another microservice (B) responsible for storing the bookings, order form the logged in user. Both microservices (A) and (B) are having a separate database. How can I store the user bookings and orders on microservice (B) based on microservice (A) using a Rest API? I'm using Django Rest framework to build my system.
I am unsure how to maintain an interface between two databases. I need guidance with the best approaches to sync data to microservice (B) when a user from microservice (A) make a booking or order

To synchronize data between microservices (A) and (B), you need to establish communication between them. One common approach is to use REST APIs to allow microservice (A) to communicate with microservice (B) over HTTP.
To implement this approach, you can design the API endpoints on microservice (B) to accept requests from microservice (A) and store the booking or order information in its own database. When a user on microservice (A) makes a booking or order, you can send a request to the relevant API endpoint on microservice (B) containing the required information.
To implement the REST API, you can use the Django Rest framework, which makes it easy to create RESTful APIs. You can define the API endpoints using the Django Rest framework's viewsets, serializers, and routers.
One challenge when using separate databases for microservices is ensuring consistency between the two databases. One approach is to use a distributed transaction management system to ensure that the data is consistent across both databases. Alternatively, you can use an event-driven architecture, where microservice (A) emits events when a user makes a booking or order, and microservice (B) listens for these events and updates its own database accordingly.
In conclusion, to sync data between microservices (A) and (B), you can implement a RESTful API using Django Rest framework. To ensure consistency between the two databases, you can use a distributed transaction management system or an event-driven architecture.

Related

Advice on cloud related architecture choices for a production mobile app calling external API [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 days ago.
This post was edited and submitted for review 5 days ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
Question:
Can the below architecture be used in production?
Mobile app serviced by Firebase(FireStore + CloudStorage) and Cloud Functions for http calls to the external API) +
AchivementsApi deployed on Appengine standard conencted with CloudSQL.
Context:
I wrote two apps that have to be used as digital support for offline gaming events.
Expected usage pattern:
The traffic starts increasing at the beginning of the week when users have to do some online tasks, then a big spike will happen in the weekend when the offline gathering is taking place. We expect to have thousands of users. In the most optimistic case, let say we will reach 8000 users.
Flutter Mobile App
a. Authentication/Profile – for this I choose Firebase as is free and scalable (also this option provides monitoring, alarms, push notifications, etc.)
b. Event related data that in most cases will not change (event timetable, exhibitors, infos... nothing intensive here) – Using the Firebase backend with Cloud Firestore db looks like the obvious choice.
c. Images can be stored on Cloud Storage or even packaged with the app
d. Integration with Achievements Api – this implies sending REST requests to the below java service, using api key for auth. A scalable and safe(storing the api key) option for this seems to be Cloud Functions. Of course, if I opt for the dedicated back end deployed on Cloud Engine or App Engine or somewhere else that service can handle the Rest calls also
Springboot Achievements Api
Service with some complex queries but no process is extremely intensive or time consuming. This must be a stand alone service available for future integrations. Due to the choice made above of using Firestore, I was thinking that this can be deployed on stantard AppEngine environment with Cloud SQL connection.

Distributed transaction using web services on different platforms

is it possible to achieve transactionality using web services that are implemented in different technologies?
For example: let's imagine a case where we want to offer an integrated service of 2 different organizations, each of which already have their different systems implemented using different technologies and located in different countries.
Organization A has a Java server exposing Rest services that allow consumers to insert data in a table, then Organization B has a .Net server exposing Rest services that also allow consumers to insert data in a table.
Then I want to create a new server to integrate both these services in one, allowing consumers to insert in both organization's databases. So from this new server I have to invoke those 2 rest services in a transactional way (meaning that both organizations will insert or none will insert if there is a failure, it will rollback).
Is that possible to achieve even tho server 1 and server 2 are implemented with different technologies? What if there were n servers all implemented in different technologies and all exposing Rest services?
It is not possible to have real transactions in case of microservice architecture. You have to implement compensations which roll back changes in case of failures. See Saga pattern for one of the approaches.
Look at the Cadence Workflow that makes implementing Sagas trivial. Here is an example.

How does a multi-tenant application fit in Microservices based architecture?

I have a SaaS based multi-tenant monolith application (built with Django), that I want to divide into microservices based architecture. But I am not sure how to divide the application into correct partitions. And on what aspects should I take care of?
In case of monolith application, it's easy to understand that I have a tenant model that decides the schemas but how this will be done in microservices if I want each service to be multi-tenant? Or should I even make the services multi-tenant?
If you're already using OAuth and/or generating JWTs for user authentication/authorization, I'd recommend any new services that need tenant scoping to require a user access token be provided in requests just like your Django app. This lets you standardize how credentials and tenant scoping is expected to be passed, and verifying JWTs is a pretty easy process to implement.
That being said, it's also important to point out that you shouldn't require that services use access tokens or have any kind of tenant scoping at all. Not only is it possible that specific services don't require tenant scoping, but it's also possible that they might want to define a tenant differently from the main Django app (e.g. a simple tenant_id). For example, a payments service that only accepts a dollar amount and a credit card doesn't care what the tenant is and would be perfectly safe to call from the main Django application (of course you should prevent public access to the service too).
The best way to think about how new services should be designed is in a vacuum - without care for how other services are designed or how they store their data. Your service was built to perform a task and it defines for itself what parameters it needs to perform that task, how it executes that task, and how it stores the data it needs for future tasks. This independence from the design of other microservices in the stack is part of the power of designing service-oriented systems. It allows creators to pick the right tools for the job, and allows them to create meaningful features without needing to collaborate with dozens of team members that they often don't know.
Hope this helps, and good luck.

What does Particular Software Service Platform exactly is? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Someone told be about this Service Platform: http://particular.net/ for implementing SOA oriented applications.
I really find it a bit confusing at first glance, so i would like to ask some questions about it:
Services are SOAP or REST?
How are data contracts and service contracts specified?
Are this services externalizable to outside consumers via WSDL metadata endpoints?
A service not implemented in .net (java, ruby) can be inserted in the service bus?
Which is the protocol used for messaging?
What are your general thoughts about this service platform?
For full disclosure, I'm the founder of the Particular Service Platform, but I'll try to keep my answers as objective as possible:
Services are SOAP or REST?
While the platform allows the use of WCF to expose endpoints for consumption by 3rd parties, the focus is on queuing - MSMQ, RabbitMQ, etc.
How are data contracts and service contracts specified?
Contracts are message-oriented from a philosophical perspective, but in practice they're just regular POCO classes and interfaces.
Are this services externalizable to outside consumers via WSDL metadata endpoints?
See the WCF comment above.
A service not implemented in .net (java, ruby) can be inserted in the service bus?
Interop can be done via WCF but the preferred model would be to use either ActiveMQ, RabbitMQ, or WebSphereMQ.
Which is the protocol used for messaging?
I'm not entirely sure what you mean by "protocol" beyond the queues mentioned above, but we support XML, Binary, and JSON serialization out of the box and also enable you to plug in your own serialization mechanism.
What are your general thoughts about this service platform?
As one of the owners of this platform, I feel my necessarily biased answer wouldn't contribute much on this point.

Recommended Web Service Architecture Books/Sites? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I'm in the position where I may be creating a new web service from scratch - without much pre-existing infrastructure to have to contend with. What resources are there that talk about the architectural aspects of deploying a web service? [Clarification: I'm not talking about an Enterprise SOA orientation here - rather setting up one family of services for the public.]
A first list of topics that I'd like to see covered are:
SOAP vs. REST
JSON vs. XML
Relational Database Backed vs. SimpleDB backed vs. ?
Scaling
Availability
Models for restricting access
Models for throttling access
What would you recommend?
I would recommend Restful Web Services. It's weel written, very complete and vendor agnostic. Also it has a fairly good coverage of both REST (with comparison to SOAP/WS-*), HTTP scaling, resource formats (JSON, XHTML, Atom, XML), security and service modeling.
If you have any specific scaling needs, then you might also want to read Building Scalable Web Sites. It will teach you everything worth knowing about etags, proxies, caching, edge computing and so forth. However if you are just starting out, then the Rest book I mentioned earlier will properly cover most people needs.
If you decide to use Microsoft technology (WCF) then you could check out the Microsoft Patterns and Practices group's online library of guidance.
They have a library located here as part of MSDN which deals with Web Service security, Enterprise Buses (obviously not applicable to you scenario) and PAG's own Web Service Software Factory.
Their main page is located here.
Otherwise, assuming you choose WCF it might be worth checking out further reading such as Juval Lowy's book on WCF, although I fear it may cover the implementation more than the theory and design facets.
Do you know roughly what technology platform you'll be working from?