@@ -2,10 +2,10 @@ Data Transfer and Abstraction
22=============================
33Abstracted APIs should attempt to hide the implementation details of
44the remote or local API in a well organized data model. This data
5- model should avoid returning raw JSON, gRPC messages, SWIG objects, or
6- .NET objects. Rather, it preferable to return standard Python objects
7- like lists, strings, dictionaries when useful, and NumPy arrays or
8- pandas dataframes for more complex data.
5+ model should avoid returning raw JSON files , gRPC messages, SWIG objects,
6+ or .NET objects. It should preferably return standard Python objects
7+ like lists, strings, dictionaries when useful, and ` NumPy < https://numpy.org/ >`_
8+ arrays or ` pandas < https://pandas.pydata.org/ >`_ dataframes for more complex data.
99
1010For example, consider a simple mesh in MAPDL:
1111
@@ -16,9 +16,9 @@ For example, consider a simple mesh in MAPDL:
1616 >> > mapdl.et(1 , 186 )
1717 >> > mapdl.vmesh(' ALL' )
1818
19- At this point, the only two ways within MAPDL to access the nodes and
20- connectivity of the mesh are either to print it using the ``NLIST ``
21- command or to write it to disk using the ``CDWRITE `` command. Both
19+ At this point, there are only two ways within MAPDL to access the nodes and
20+ connectivity of the mesh, You can either print it using the ``NLIST ``
21+ command or write it to disk using the ``CDWRITE `` command. Both of these
2222methods are remarkably inefficient, requiring:
2323
2424- Serializing the data to ASCII on the server
@@ -65,28 +65,28 @@ within the MAPDL database.
6565 [0.75 , 0.5 , 0.5 ]])
6666
6767
68- REST vs RPC Data and Model Abstraction
69- --------------------------------------
70- Because of the nature of Ansys's products, our applications and
71- services can either fit into the RPC interface where the API is
72- centered around operations and commands, or the REST model which is
73- centered around resources. Regardless of the the interface style,
74- there are several items to consider.
68+ REST Versus RPC Data and Model Abstraction
69+ ------------------------------------------
70+ Because of the nature of most Ansys products, our applications and
71+ services can either fit into the RPC interface, where the API is
72+ centered around operations and commands, or the REST model, where
73+ the API is centered around resources. Regardless of the the interface
74+ style, there are several items to consider.
7575
7676
7777API Chattiness
7878~~~~~~~~~~~~~~
79- APIs must be efficient to avoid creating chatty I/O. Because many of
80- Ansys's products fit well with the RPC API implementation, there is a
81- temptation to design APIs that require constant communication with the
82- remote or local service. However, just because RPC interfaces can,
83- does not mean they should as it should be assumed that each RPC call
84- takes significant time to execute.
85-
86- One way to avoid this approach is to either serialize several
87- "commands" for services that employ an internal "command pattern" for
88- data exchange. Another approach is to encapsulate the data model
89- entirely on the server and avoid data transfer whenever possible and
79+ APIs must be efficient to avoid creating chatty input and output.
80+ Because many Ansys products fit well with the RPC API implementation,
81+ there is a temptation to design APIs that require constant communication
82+ with the remote or local service. However, just because RPC interfaces
83+ can do this, it does not mean that they should. The assumption should be
84+ that each RPC call takes significant time to execute.
85+
86+ One way to avoid constant communication with the service is to serialize
87+ several "commands" for services that employ an internal "command pattern"
88+ for data exchange. Another approach is to encapsulate the data model
89+ entirely on the server to avoid data transfer whenever possible and
9090expose only a limited number of RPC methods in the front-facing API.
9191
9292Compatibility and Efficiency
@@ -97,16 +97,15 @@ of the first choices due to its compatibility with nearly all popular
9797languages and its efficiency over REST in terms of speed, memory, and
9898payload size.
9999
100- Typically, data exchange over REST should be limited to short messages
101- exchanged over JSON, whereas gRPC can handle large data transfer and
102- even allows for bidirectional streaming.
103-
104- In general, it is preferable to choose gRPC over REST due to the
105- performance benefits of a binary compatible protocol. While REST
106- carries a variety of benefits, for complex client/server interactions,
107- it is best to have an interface that can efficiently exchange a wide
108- variety of data formats and messages.
100+ Typically, REST data exchanges should be limited to short messages
101+ transferred via JSON files, and gRPC should be used for large data
102+ transfers and bidirectional streaming.
109103
104+ Choosing gRPC over REST is generally preferable due to the performance
105+ benefits of a binary compatible protocol. While REST provides a variety of
106+ benefits, for complex client/server interactions, it is best to have an
107+ interface that can efficiently exchange a wide variety of data formats and
108+ messages.
110109
111110
112111.. _gRPC : https://grpc.io/
0 commit comments